Push the locale under both keys, because every reader prefers one of them

The push wrote `lang`. Every reader takes `locale` FIRST and only then falls
back to `lang`: ProfileLoader.vue:189, and people-groups-grid.vue at :273 and
:380. So writing one key is correct exactly while no child config carries the
other, and stops working silently the day one does -- a `locale` left by a boot
copy or a host-list path would shadow every fresh `lang` we push, for the rest
of the session, with both values sitting in the same object.

Writing both keeps them in step whatever put them there.

Not broken today: the nested configs were measured carrying no locale key at
all. This closes the class rather than a symptom, which is worth one line.

Shown by driving the real function: with a stale {lang:'en', locale:'en'} the
push now yields ar in both keys, and a config carrying only `locale` switches
too. Reverting to the lang-only write leaves {lang:'ar', locale:'en'} -- the
exact shadowing above, where the map reads English while holding a fresh lang.
This commit is contained in:
Doxa Maps 2026-09-29 19:46:51 +00:00
parent 75baaa82a6
commit d975337501

View file

@ -444,7 +444,13 @@ function pushToChildren() {
// every push. MEASURED: the map stayed English on a live en->ar switch while the composite
// around it changed. The leaf's own chain is fully reactive and was never at fault — it is
// reactive to its own prop, and its prop was frozen.
if (hostLang.value) cfg.lang = hostLang.value
// BOTH KEYS, and `locale` is the one that decides. Every reader takes locale FIRST and falls
// back to lang — ProfileLoader.vue:189 and people-groups-grid.vue:273/380 all read
// `config.locale || config.lang`. Writing only `lang` is therefore correct exactly while no
// child config carries a `locale`, and silently stops working the day one does: a stale locale
// from a boot copy or a host-list path would shadow every fresh lang we push, forever. Writing
// both keeps the two in step whatever put them there.
if (hostLang.value) { cfg.lang = hostLang.value; cfg.locale = hostLang.value }
map.setAttribute('profile-config', JSON.stringify(cfg))
}
const grid = rootEl.querySelector('people-groups-grid')
@ -461,8 +467,9 @@ function pushToChildren() {
if (hostLang.value) {
let gcfg = {}
try { gcfg = JSON.parse(grid.getAttribute('profile-config') || '{}') } catch (_) { gcfg = {} }
if (gcfg.lang !== hostLang.value) {
if (gcfg.lang !== hostLang.value || gcfg.locale !== hostLang.value) {
gcfg.lang = hostLang.value
gcfg.locale = hostLang.value
grid.setAttribute('profile-config', JSON.stringify(gcfg))
}
}