@lumx/react 4.12.0-next.2 → 4.12.0-next.3

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/index.js CHANGED
@@ -2509,6 +2509,9 @@ const ENABLED_CHIP_SELECTOR = `.${CLASSNAME$1j}:not([aria-disabled="true"])`;
2509
2509
  /** Find the closest chip element from an event target. */
2510
2510
  const getChip = target => target?.closest?.(`.${CLASSNAME$1j}`) || null;
2511
2511
 
2512
+ /** Whether the chip is marked as disabled via aria-disabled. */
2513
+ const isChipDisabled = chip => chip?.getAttribute('aria-disabled') === 'true';
2514
+
2512
2515
  /**
2513
2516
  * Options for setting up selection chip group event handlers.
2514
2517
  * All option accessors are wrapped in getters so that React/Vue can provide
@@ -2563,7 +2566,9 @@ function setupSelectionChipGroupEvents(options) {
2563
2566
  const handleClick = evt => {
2564
2567
  const chip = getChip(evt.target);
2565
2568
  const optionId = chip?.dataset.optionId;
2566
- if (optionId == null) return;
2569
+ if (optionId == null || isChipDisabled(chip)) {
2570
+ return;
2571
+ }
2567
2572
  evt.stopImmediatePropagation();
2568
2573
  removeOption(options, optionId);
2569
2574
  };
@@ -2576,7 +2581,9 @@ function setupSelectionChipGroupEvents(options) {
2576
2581
  const chip = getChip(evt.target);
2577
2582
  const optionId = chip?.dataset.optionId;
2578
2583
  const activatingKey = evt.key === 'Enter' || evt.key === ' ' || evt.key === 'Backspace';
2579
- if (optionId == null || !activatingKey) return;
2584
+ if (optionId == null || !activatingKey || isChipDisabled(chip)) {
2585
+ return;
2586
+ }
2580
2587
  if (evt.key === 'Backspace') {
2581
2588
  // Move focus to previous option (instead of next in listbox)
2582
2589
  const previousChip = findPreviousChip(container, chip);