@justai/cuts 0.36.0 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justai/cuts",
3
- "version": "0.36.0",
3
+ "version": "0.37.0",
4
4
  "description": "A persona's named parts \u2014 the page shell that holds them, and the cuts themselves.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -154,13 +154,34 @@ const ordered = orderLocales(locales);
154
154
  });
155
155
  sheet?.addEventListener("close", () => trigger.setAttribute("aria-expanded", "false"));
156
156
 
157
- // Remember the chosen language for auto-routing on the next visit.
157
+ // queries: language picker does not close · choosing a language does nothing · route-less
158
+ // locale switch · the sheet stays open after picking a language · /me /files language
159
+ //
160
+ // Remember the choice, then GO — and "go" has two shapes, because two kinds of consumer exist.
161
+ //
162
+ // A persona with per-locale routes navigates to /<lang>/, carrying the section it was on. A
163
+ // ROUTE-LESS surface — /me, /files: one bundle mounted at one path on thirteen hosts, translated
164
+ // in the browser — hands back the page it is already on, because there is nowhere else to go.
165
+ //
166
+ // The second case was broken from the day those surfaces adopted this cut, and it broke quietly:
167
+ // `location.assign("/me" + "#kernel")` on a page already at `/me#kernel` is the SAME URL, so the
168
+ // browser correctly does nothing. The choice was written to localStorage, no navigation
169
+ // happened, the sheet stayed open and the words stayed English. It looked like a picker that
170
+ // ignores you.
158
171
  for (const it of items) {
159
172
  it.addEventListener("click", (e) => {
160
- localStorage.setItem("lang", it.dataset.lang ?? "en");
161
- // preserve the section you're viewing (Profile/Kernel/Posts) across the language switch
173
+ try { localStorage.setItem("lang", it.dataset.lang ?? "en"); } catch { /* a locked jar is not a reason to refuse the click */ }
162
174
  const href = it.getAttribute("href");
163
- if (href && location.hash) { e.preventDefault(); location.assign(href + location.hash); }
175
+ if (!href) return;
176
+ const to = new URL(href, location.href);
177
+ if (to.pathname === location.pathname && to.search === location.search) {
178
+ // Same document: the only way to re-render is to reload it.
179
+ e.preventDefault();
180
+ location.reload();
181
+ return;
182
+ }
183
+ // preserve the section you're viewing (Profile/Kernel/Posts) across the language switch
184
+ if (location.hash) { e.preventDefault(); location.assign(href + location.hash); }
164
185
  });
165
186
  }
166
187
  }