@lumx/react 4.17.0-next.0 → 4.17.0-next.1

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.
Files changed (3) hide show
  1. package/index.js +20 -19
  2. package/index.js.map +1 -1
  3. package/package.json +3 -3
package/index.js CHANGED
@@ -6377,7 +6377,7 @@ function setupListbox(handle, signal, notify, options) {
6377
6377
  wrap: options?.wrapNavigation,
6378
6378
  getActiveItem: () => {
6379
6379
  const id = trigger.getAttribute('aria-activedescendant');
6380
- return id ? document.getElementById(id) : null;
6380
+ return id && listbox.querySelector(`#${CSS.escape(id)}`) || null;
6381
6381
  }
6382
6382
  }, focusCallbacks, signal);
6383
6383
  }
@@ -6399,11 +6399,6 @@ function setupListbox(handle, signal, notify, options) {
6399
6399
  }
6400
6400
  handle.select(cell);
6401
6401
  trigger.focus();
6402
-
6403
- // In multi-select mode, keep visual focus on the selected option
6404
- if (!handle.isMultiSelect) {
6405
- handle.setIsOpen(false);
6406
- }
6407
6402
  }, {
6408
6403
  signal
6409
6404
  });
@@ -6593,10 +6588,6 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
6593
6588
  if (!isOptionDisabled(activeItem)) {
6594
6589
  activeItem.click();
6595
6590
  }
6596
- // Only close when not in multi select and not in action cell
6597
- if (!handle.isMultiSelect && !isActionCell(activeItem)) {
6598
- handle.setIsOpen(false);
6599
- }
6600
6591
  flag = true;
6601
6592
  } else if (handle.isOpen && !handle.isMultiSelect) {
6602
6593
  // Open with no active item (single select) => close the popup,
@@ -6751,6 +6742,15 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
6751
6742
  callbacks.onSelect?.({
6752
6743
  value: option ? getOptionValue(option) : ''
6753
6744
  });
6745
+
6746
+ // Close on selection (when not multiselectable)
6747
+ if (option && !handle.isMultiSelect) {
6748
+ handle.focusNav?.clear();
6749
+ // Defer the close to the next frame (to make sure all other click handler resolve).
6750
+ requestAnimationFrame(() => {
6751
+ handle.setIsOpen(false);
6752
+ });
6753
+ }
6754
6754
  },
6755
6755
  flushPendingNavigation() {
6756
6756
  // Do navigations actions we could not do because the combobox items were not mounted yet
@@ -7349,7 +7349,8 @@ function setupComboboxInput(input, options) {
7349
7349
  let handle;
7350
7350
  const {
7351
7351
  filter = 'auto',
7352
- onSelect: optionOnSelect
7352
+ onSelect: optionOnSelect,
7353
+ onInput: onInputCallback
7353
7354
  } = options;
7354
7355
  const openOnFocus = options.openOnFocus ?? filter === 'off';
7355
7356
  const autoFilter = filter === 'auto';
@@ -7366,18 +7367,11 @@ function setupComboboxInput(input, options) {
7366
7367
 
7367
7368
  /**
7368
7369
  * Wraps the consumer's onSelect to perform input-mode side effects after selection:
7369
- * clears the active descendant, resets the filter, and re-opens the popup.
7370
+ * resets the filter and typing state.
7370
7371
  */
7371
7372
  const onSelect = option => {
7372
7373
  optionOnSelect?.(option);
7373
-
7374
- // Clear the active item. In multi-select, keep visual focus so the
7375
- // user can continue navigating after selection.
7376
- if (!handle.isMultiSelect) {
7377
- handle.focusNav?.clear();
7378
- }
7379
7374
  userHasTyped = false;
7380
- handle.setIsOpen(true);
7381
7375
  if (autoFilter) {
7382
7376
  handle.setFilter('');
7383
7377
  }
@@ -7397,6 +7391,9 @@ function setupComboboxInput(input, options) {
7397
7391
  if (isDisabled()) return;
7398
7392
  combobox.focusNav?.clear();
7399
7393
  userHasTyped = true;
7394
+
7395
+ // Notify the framework wrapper of the new input value synchronously.
7396
+ onInputCallback?.(input.value);
7400
7397
  combobox.setIsOpen(true);
7401
7398
  if (autoFilter) {
7402
7399
  combobox.setFilter(input.value);
@@ -8141,6 +8138,10 @@ const ComboboxInput = forwardRef((props, ref) => {
8141
8138
  onChangeRef.current?.(option.value);
8142
8139
  onSelectRef.current?.(option);
8143
8140
  },
8141
+ onInput(value) {
8142
+ // Keep controlled value in sync.
8143
+ onChangeRef.current?.(value);
8144
+ },
8144
8145
  filter,
8145
8146
  openOnFocus
8146
8147
  });