@lumx/react 4.19.0 → 4.19.1-alpha.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 +27 -2
  2. package/index.js.map +1 -1
  3. package/package.json +4 -3
package/index.js CHANGED
@@ -6415,6 +6415,29 @@ 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
+ const debounced = () => {
6425
+ if (!running) {
6426
+ running = true;
6427
+ queueMicrotask(() => {
6428
+ if (running) {
6429
+ running = false;
6430
+ fn();
6431
+ }
6432
+ });
6433
+ }
6434
+ };
6435
+ debounced.cancel = () => {
6436
+ running = false;
6437
+ };
6438
+ return debounced;
6439
+ }
6440
+
6418
6441
  /** Options for configuring the shared combobox behavior. */
6419
6442
 
6420
6443
  /**
@@ -6499,8 +6522,9 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
6499
6522
  * or if the input value changed while the list is empty (so `emptyMessage` callbacks get
6500
6523
  * the updated query string).
6501
6524
  * Called whenever the set of visible options may have changed (option register/unregister, filter change).
6525
+ * (debounced in a microtask)
6502
6526
  */
6503
- function notifyVisibilityChange() {
6527
+ const notifyVisibilityChange = debounceMicrotask(() => {
6504
6528
  for (const [sectionElement] of sectionRegistrations) {
6505
6529
  notifySection(sectionElement, sectionRegistrations, optionRegistrations);
6506
6530
  }
@@ -6521,7 +6545,7 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
6521
6545
  if (isOpenState) {
6522
6546
  trigger?.setAttribute('aria-expanded', String(hasVisibleContent()));
6523
6547
  }
6524
- }
6548
+ });
6525
6549
 
6526
6550
  // ── Skeleton loading tracking ──────────────────────────────
6527
6551
 
@@ -6918,6 +6942,7 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
6918
6942
  optionRegistrations.clear();
6919
6943
  sectionRegistrations.clear();
6920
6944
  skeletonCount = 0;
6945
+ notifyVisibilityChange.cancel();
6921
6946
  clearTimeout(loadingTimer);
6922
6947
  announcementSent = false;
6923
6948
  // Clear all subscribers