@lumx/react 4.19.0-next.1 → 4.19.1-alpha.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.
Files changed (3) hide show
  1. package/index.js +20 -2
  2. package/index.js.map +1 -1
  3. package/package.json +4 -4
package/index.js CHANGED
@@ -6415,6 +6415,23 @@ function setupListbox(handle, signal, notify, options) {
6415
6415
  return focusNav;
6416
6416
  }
6417
6417
 
6418
+ /**
6419
+ * Wrap `fn` so that, no matter how many times the returned function is called within the same
6420
+ * microtask cycle, `fn` only runs once at the end of that cycle.
6421
+ */
6422
+ function debounceMicrotask(fn) {
6423
+ let running = false;
6424
+ return () => {
6425
+ if (!running) {
6426
+ running = true;
6427
+ queueMicrotask(() => {
6428
+ fn();
6429
+ running = false;
6430
+ });
6431
+ }
6432
+ };
6433
+ }
6434
+
6418
6435
  /** Options for configuring the shared combobox behavior. */
6419
6436
 
6420
6437
  /**
@@ -6499,8 +6516,9 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
6499
6516
  * or if the input value changed while the list is empty (so `emptyMessage` callbacks get
6500
6517
  * the updated query string).
6501
6518
  * Called whenever the set of visible options may have changed (option register/unregister, filter change).
6519
+ * (debounced in a microtask)
6502
6520
  */
6503
- function notifyVisibilityChange() {
6521
+ const notifyVisibilityChange = debounceMicrotask(() => {
6504
6522
  for (const [sectionElement] of sectionRegistrations) {
6505
6523
  notifySection(sectionElement, sectionRegistrations, optionRegistrations);
6506
6524
  }
@@ -6521,7 +6539,7 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
6521
6539
  if (isOpenState) {
6522
6540
  trigger?.setAttribute('aria-expanded', String(hasVisibleContent()));
6523
6541
  }
6524
- }
6542
+ });
6525
6543
 
6526
6544
  // ── Skeleton loading tracking ──────────────────────────────
6527
6545