tosijs-ui 1.5.21 → 1.5.23

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/dist/menu.js CHANGED
@@ -995,8 +995,8 @@ export const createMenuAction = (item, options) => {
995
995
  if (item.tooltip) {
996
996
  menuItem.dataset.tooltip = item.tooltip;
997
997
  }
998
- if (options.role === 'listbox' && checked) {
999
- menuItem.setAttribute('aria-selected', 'true');
998
+ if (options.role === 'listbox') {
999
+ menuItem.toggleAttribute('aria-selected', checked !== false);
1000
1000
  }
1001
1001
  if (item?.enabled && !item.enabled()) {
1002
1002
  menuItem.setAttribute('disabled', '');
@@ -47,11 +47,11 @@ export declare class TosiSegmented extends WebComponent {
47
47
  boxShadow: string;
48
48
  borderRadius: string;
49
49
  };
50
- ':host label:has(:checked)': {
50
+ ':host label.current': {
51
51
  color: string;
52
52
  background: string;
53
53
  };
54
- ':host label:has(:checked):focus': {
54
+ ':host label.current:focus': {
55
55
  boxShadow: string;
56
56
  };
57
57
  ':host svg': {
@@ -86,6 +86,7 @@ export declare class TosiSegmented extends WebComponent {
86
86
  opacity: string;
87
87
  };
88
88
  };
89
+ private syncCurrent;
89
90
  private valueChanged;
90
91
  handleChange: () => void;
91
92
  handleKey: (event: KeyboardEvent) => void;
package/dist/segmented.js CHANGED
@@ -218,11 +218,15 @@ export class TosiSegmented extends WebComponent {
218
218
  boxShadow: varDefault.segmentedFocusShadow(`inset 0 0 0 2px ${varDefault.segmentedOptionCurrentBackground('#44a')}`),
219
219
  borderRadius: varDefault.segmentedOptionsBorderRadius('8px'),
220
220
  },
221
- ':host label:has(:checked)': {
221
+ // Selection highlight is driven by an explicit `.current` class rather than
222
+ // `label:has(:checked)`. Firefox does not reliably re-evaluate `:has(:checked)`
223
+ // when a descendant radio's checked state changes via interaction, leaving the
224
+ // previously-selected segment highlighted (works in Chrome/Safari).
225
+ ':host label.current': {
222
226
  color: varDefault.segmentedOptionCurrentColor('#eee'),
223
227
  background: varDefault.segmentedOptionCurrentBackground('#44a'),
224
228
  },
225
- ':host label:has(:checked):focus': {
229
+ ':host label.current:focus': {
226
230
  boxShadow: varDefault.segmentedCurrentFocusShadow(`inset 0 0 0 2px ${varDefault.segmentedOptionCurrentColor('#eee')}`),
227
231
  },
228
232
  ':host svg': {
@@ -257,6 +261,16 @@ export class TosiSegmented extends WebComponent {
257
261
  opacity: varDefault.segmentedPlaceholderOpacity(0.75),
258
262
  },
259
263
  };
264
+ // Reflects each radio/checkbox's checked state onto its containing label as a
265
+ // `.current` class so the selection highlight updates reliably (see note on the
266
+ // `.current` style rule).
267
+ syncCurrent() {
268
+ const { options } = this.parts;
269
+ options.querySelectorAll('label').forEach((label) => {
270
+ const input = label.querySelector('input');
271
+ label.classList.toggle('current', Boolean(input && input.checked));
272
+ });
273
+ }
260
274
  valueChanged = false;
261
275
  handleChange = () => {
262
276
  const { options, custom } = this.parts;
@@ -282,6 +296,7 @@ export class TosiSegmented extends WebComponent {
282
296
  this.value = custom.value;
283
297
  }
284
298
  }
299
+ this.syncCurrent();
285
300
  this.valueChanged = true;
286
301
  };
287
302
  handleKey = (event) => {
@@ -386,6 +401,7 @@ export class TosiSegmented extends WebComponent {
386
401
  custom.placeholder = this.placeholder;
387
402
  options.append(custom);
388
403
  }
404
+ this.syncCurrent();
389
405
  }
390
406
  }
391
407
  /** @deprecated Use TosiSegmented instead */
@@ -50,7 +50,7 @@ export declare class TosiTabs extends WebComponent {
50
50
  display: string;
51
51
  alignItems: string;
52
52
  };
53
- ':host .tabs > [aria-selected="true"]': {
53
+ ':host .tabs > [aria-selected]': {
54
54
  '--text-color': string;
55
55
  color: string;
56
56
  };
@@ -209,7 +209,7 @@ export class TosiTabs extends WebComponent {
209
209
  display: 'flex',
210
210
  alignItems: 'baseline',
211
211
  },
212
- ':host .tabs > [aria-selected="true"]': {
212
+ ':host .tabs > [aria-selected]': {
213
213
  '--text-color': vars.tosiTabsSelectedColor,
214
214
  color: vars.textColor,
215
215
  },
@@ -342,15 +342,12 @@ export class TosiTabs extends WebComponent {
342
342
  for (let i = 0; i < tabBodies.length; i++) {
343
343
  const tabBody = tabBodies[i];
344
344
  const tab = tabs.children[i];
345
- if (this.value === Number(i)) {
346
- tab.setAttribute('aria-selected', 'true');
345
+ const isSelected = this.value === Number(i);
346
+ tab.toggleAttribute('aria-selected', isSelected);
347
+ tabBody.toggleAttribute('hidden', !isSelected);
348
+ if (isSelected) {
347
349
  selected.style.marginLeft = `${tab.offsetLeft - tabs.offsetLeft}px`;
348
350
  selected.style.width = `${tab.offsetWidth}px`;
349
- tabBody.toggleAttribute('hidden', false);
350
- }
351
- else {
352
- tab.toggleAttribute('aria-selected', false);
353
- tabBody.toggleAttribute('hidden', true);
354
351
  }
355
352
  }
356
353
  }