diff --git a/plugin-designs/dashboard-plus-grid/dashboard-plus-grid.vue b/plugin-designs/dashboard-plus-grid/dashboard-plus-grid.vue index 7a410d29d..978813493 100644 --- a/plugin-designs/dashboard-plus-grid/dashboard-plus-grid.vue +++ b/plugin-designs/dashboard-plus-grid/dashboard-plus-grid.vue @@ -298,9 +298,19 @@ const textDir = computed(() => { const l = hostLang.value || getRuntimeLocale() || detectLocale() return RTL_LOCALES.has(l) ? 'rtl' : 'ltr' }) +// ★ THE INSTANCE IS CAPTURED IN SETUP, NOT READ WHEN THIS RUNS, and that is the whole bug. +// getCurrentInstance() answers only while setup or a lifecycle hook is on the stack. reflectDir is +// called from BOTH — onMounted (where it works) and watch(textDir) (where there is no current +// instance, so the read returned null and nothing was reflected). So a host that set lang=ar before +// mount got dir=rtl correctly, and a host that SWITCHED to ar afterwards silently got nothing: +// first paint was right, which is exactly why this read as correct. Arabic then rendered in a +// left-to-right layout — the failure the comment above calls "a styling quirk rather than the bug +// it is". Measured in this tree before, under Vue 3.5.42, when research-map.vue's emitFilterState +// died the same way; the fix is its _selfInstance, and this is the same fix. +const _selfInstance = getCurrentInstance() function reflectDir() { try { - const host = getCurrentInstance()?.proxy?.$el?.getRootNode?.()?.host + const host = _selfInstance?.proxy?.$el?.getRootNode?.()?.host if (host && textDir.value === 'rtl') host.setAttribute('dir', 'rtl') } catch (_) { /* no host (SSR/tests) — nothing to reflect */ } } diff --git a/plugin-designs/research-map-plus-grid/research-map-plus-grid.vue b/plugin-designs/research-map-plus-grid/research-map-plus-grid.vue index 305eebad5..6a466d869 100644 --- a/plugin-designs/research-map-plus-grid/research-map-plus-grid.vue +++ b/plugin-designs/research-map-plus-grid/research-map-plus-grid.vue @@ -147,9 +147,19 @@ const textDir = computed(() => { const l = hostLang.value || getRuntimeLocale() || detectLocale() return RTL_LOCALES.has(l) ? 'rtl' : 'ltr' }) +// ★ THE INSTANCE IS CAPTURED IN SETUP, NOT READ WHEN THIS RUNS, and that is the whole bug. +// getCurrentInstance() answers only while setup or a lifecycle hook is on the stack. reflectDir is +// called from BOTH — onMounted (where it works) and watch(textDir) (where there is no current +// instance, so the read returned null and nothing was reflected). So a host that set lang=ar before +// mount got dir=rtl correctly, and a host that SWITCHED to ar afterwards silently got nothing: +// first paint was right, which is exactly why this read as correct. Arabic then rendered in a +// left-to-right layout — the failure the comment above calls "a styling quirk rather than the bug +// it is". Measured in this tree before, under Vue 3.5.42, when research-map.vue's emitFilterState +// died the same way; the fix is its _selfInstance, and this is the same fix. +const _selfInstance = getCurrentInstance() function reflectDir() { try { - const host = getCurrentInstance()?.proxy?.$el?.getRootNode?.()?.host + const host = _selfInstance?.proxy?.$el?.getRootNode?.()?.host if (host && textDir.value === 'rtl') host.setAttribute('dir', 'rtl') } catch (_) { /* no host (SSR/tests) — nothing to reflect */ } }