@smilodon/core 1.11.1 → 1.13.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.
package/dist/index.js CHANGED
@@ -2121,8 +2121,10 @@ const defaultConfig = {
2121
2121
  busyBucket: {
2122
2122
  enabled: true,
2123
2123
  showSpinner: true,
2124
+ showMessage: true,
2124
2125
  message: 'Loading...',
2125
2126
  minDisplayTime: 200,
2127
+ contentMode: 'append',
2126
2128
  },
2127
2129
  styles: {
2128
2130
  classNames: {},
@@ -4041,6 +4043,10 @@ class EnhancedSelect extends HTMLElement {
4041
4043
  super();
4042
4044
  this._dataLoadingConfig = { ...LEGACY_DATA_LOADING_CONFIG };
4043
4045
  this._hasLastInvalidDataLoadingCandidate = false;
4046
+ this._busyPresentationVisible = false;
4047
+ this._busyPresentationStartedAt = null;
4048
+ this._busyPresentationGeneration = 0;
4049
+ this._busyPresentationHideTimer = null;
4044
4050
  this._engine = new SelectEngineBridge();
4045
4051
  this._virtualizationScope = {
4046
4052
  dataKeys: [],
@@ -4135,6 +4141,22 @@ class EnhancedSelect extends HTMLElement {
4135
4141
  this._renderCycleWaiterTimeouts = new Map();
4136
4142
  this._suppressNextOpenClick = false;
4137
4143
  this._resolvedDropdownPlacement = 'bottom';
4144
+ // Presentation only: the popup engine is already closed while the exit runs.
4145
+ this._dropdownExitTimer = null;
4146
+ this._onDropdownExitAnimationEnd = (event) => {
4147
+ if (event.target !== this._dropdown || this._state.isOpen)
4148
+ return;
4149
+ if (this._dropdown.getAttribute('data-motion') !== 'closing')
4150
+ return;
4151
+ // A composite consumer animation must finish all timelines, not just the first.
4152
+ const names = getComputedStyle(this._dropdown).animationName
4153
+ .split(',').map((name) => name.trim()).filter((name) => name && name !== 'none');
4154
+ if (names.length > 1)
4155
+ return; // bounded timeout waits for the longest timeline
4156
+ if (event.animationName && names[0] && event.animationName !== names[0])
4157
+ return;
4158
+ this._finishDropdownExit();
4159
+ };
4138
4160
  this._multiScrollDrag = {
4139
4161
  active: false,
4140
4162
  moved: false,
@@ -4288,6 +4310,7 @@ class EnhancedSelect extends HTMLElement {
4288
4310
  this._syncListboxAccessibility();
4289
4311
  }
4290
4312
  disconnectedCallback() {
4313
+ this._cancelBusyPresentation();
4291
4314
  if (this._dataRequestCoordinator) {
4292
4315
  const actions = this._dataRequestCoordinator.disconnect();
4293
4316
  this._acknowledgedReady = false;
@@ -4296,6 +4319,11 @@ class EnhancedSelect extends HTMLElement {
4296
4319
  this._state.isSearching = false;
4297
4320
  this._state.preserveScrollPosition = false;
4298
4321
  }
4322
+ // A disconnected popup must not retain a visual exit or a live timer.
4323
+ this._cancelDropdownExit();
4324
+ this._dropdown.style.display = 'none';
4325
+ this._dropdown.setAttribute('inert', '');
4326
+ this._dropdown.setAttribute('aria-hidden', 'true');
4299
4327
  // unregister instance
4300
4328
  EnhancedSelect._instances.delete(this);
4301
4329
  if (this._state.isOpen) {
@@ -5649,6 +5677,12 @@ class EnhancedSelect extends HTMLElement {
5649
5677
  --select-dropdown-top: calc(100% + 6px);
5650
5678
  --select-dropdown-bottom: calc(100% + 6px);
5651
5679
  --select-dropdown-animation: dropdownEnter 200ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
5680
+ --select-dropdown-exit-animation: dropdownExit 160ms cubic-bezier(0.4, 0, 1, 1) forwards;
5681
+ --select-dropdown-exit-from-opacity: 1;
5682
+ --select-dropdown-exit-from-transform: translateY(0) scale(1);
5683
+ --select-dropdown-exit-to-opacity: 0;
5684
+ --select-dropdown-exit-to-transform: translateY(-8px) scale(0.98);
5685
+ --select-dropdown-top-exit-to-transform: translateY(8px) scale(0.98);
5652
5686
  --select-dropdown-enter-from-opacity: 0;
5653
5687
  --select-dropdown-enter-from-transform: translateY(-8px) scale(0.98);
5654
5688
  --select-dropdown-enter-to-opacity: 1;
@@ -6351,8 +6385,26 @@ class EnhancedSelect extends HTMLElement {
6351
6385
 
6352
6386
  .select-dropdown[data-placement="top"] {
6353
6387
  --select-dropdown-enter-from-transform: var(--select-dropdown-top-enter-from-transform, translateY(8px) scale(0.98));
6388
+ --select-dropdown-exit-to-transform: var(--select-dropdown-top-exit-to-transform, translateY(8px) scale(0.98));
6354
6389
  }
6355
-
6390
+
6391
+ /* A closed popup stays visually mounted for exit, but cannot be interacted with. */
6392
+ .select-dropdown[data-motion="closing"] {
6393
+ animation: var(--select-dropdown-exit-animation);
6394
+ pointer-events: none;
6395
+ }
6396
+
6397
+ @keyframes dropdownExit {
6398
+ from {
6399
+ opacity: var(--select-dropdown-exit-from-opacity);
6400
+ transform: var(--select-dropdown-exit-from-transform);
6401
+ }
6402
+ to {
6403
+ opacity: var(--select-dropdown-exit-to-opacity);
6404
+ transform: var(--select-dropdown-exit-to-transform);
6405
+ }
6406
+ }
6407
+
6356
6408
  @keyframes dropdownEnter {
6357
6409
  0% {
6358
6410
  opacity: var(--select-dropdown-enter-from-opacity);
@@ -6601,12 +6653,40 @@ class EnhancedSelect extends HTMLElement {
6601
6653
  }
6602
6654
 
6603
6655
  .busy-bucket {
6656
+ display: flex;
6657
+ flex-direction: column;
6658
+ align-items: center;
6659
+ justify-content: center;
6660
+ gap: var(--select-busy-gap, 8px);
6604
6661
  padding: var(--select-busy-padding, 20px);
6605
6662
  text-align: center;
6606
6663
  color: var(--select-busy-color, var(--select-text-muted));
6607
6664
  background: var(--select-busy-bg, transparent);
6608
6665
  font-size: var(--select-busy-font-size, 0.8667em);
6609
6666
  }
6667
+
6668
+ .busy-icon {
6669
+ display: flex;
6670
+ align-items: center;
6671
+ justify-content: center;
6672
+ }
6673
+
6674
+ .busy-icon[hidden] {
6675
+ display: none;
6676
+ }
6677
+
6678
+ .busy-message {
6679
+ text-align: center;
6680
+ }
6681
+
6682
+ .busy-content[hidden] {
6683
+ display: none;
6684
+ }
6685
+
6686
+ .busy-bucket--replace .busy-icon,
6687
+ .busy-bucket--replace .busy-message {
6688
+ display: none;
6689
+ }
6610
6690
 
6611
6691
  .spinner {
6612
6692
  display: inline-block;
@@ -7358,6 +7438,10 @@ class EnhancedSelect extends HTMLElement {
7358
7438
  if (!effects.some((effect) => effect.type === 'POPUP_OPENED'))
7359
7439
  return;
7360
7440
  this._runEngineEffects(effects);
7441
+ // Reopening during exit cancels the old finish callback and restores interactivity.
7442
+ this._cancelDropdownExit();
7443
+ this._dropdown.removeAttribute('inert');
7444
+ this._dropdown.removeAttribute('aria-hidden');
7361
7445
  this._markOpenStart();
7362
7446
  this.setAttribute('data-open', 'true');
7363
7447
  this._liftStackingAncestors();
@@ -7394,14 +7478,78 @@ class EnhancedSelect extends HTMLElement {
7394
7478
  return;
7395
7479
  this.removeAttribute('data-open');
7396
7480
  this._restoreLiftedAncestors();
7397
- this._dropdown.style.display = 'none';
7398
7481
  this._dropdown.setAttribute('data-placement', this._resolvedDropdownPlacement);
7399
7482
  this._updateArrowRotation();
7483
+ // Engine + ARIA close immediately. Only the visual panel waits for exit.
7400
7484
  this._runEngineEffects(effects);
7485
+ this._beginDropdownExit(reason === 'disconnect' || !this.isConnected);
7401
7486
  this._emit('close', {});
7402
7487
  this._config.callbacks.onClose?.();
7403
7488
  this._announce('Options collapsed');
7404
7489
  }
7490
+ /** Stop an outstanding exit before reopening, disconnecting or starting another one. */
7491
+ _cancelDropdownExit() {
7492
+ if (this._dropdownExitTimer !== null) {
7493
+ window.clearTimeout(this._dropdownExitTimer);
7494
+ this._dropdownExitTimer = null;
7495
+ }
7496
+ this._dropdown.removeEventListener('animationend', this._onDropdownExitAnimationEnd);
7497
+ this._dropdown.removeAttribute('data-motion');
7498
+ }
7499
+ _finishDropdownExit() {
7500
+ if (this._state.isOpen || this._dropdown.getAttribute('data-motion') !== 'closing')
7501
+ return;
7502
+ this._cancelDropdownExit();
7503
+ this._dropdown.style.display = 'none';
7504
+ }
7505
+ _beginDropdownExit(immediate) {
7506
+ this._cancelDropdownExit();
7507
+ // Inert + aria-hidden apply at logical close, not at animation completion.
7508
+ this._dropdown.setAttribute('inert', '');
7509
+ this._dropdown.setAttribute('aria-hidden', 'true');
7510
+ if (immediate || this._dropdown.style.display === 'none') {
7511
+ this._dropdown.style.display = 'none';
7512
+ return;
7513
+ }
7514
+ this._dropdown.setAttribute('data-motion', 'closing');
7515
+ const duration = this._getDropdownExitDurationMs();
7516
+ if (duration <= 0) {
7517
+ this._finishDropdownExit();
7518
+ return;
7519
+ }
7520
+ // animationend optimizes normal completion; timeout handles missing/cancelled events.
7521
+ this._dropdown.addEventListener('animationend', this._onDropdownExitAnimationEnd);
7522
+ this._dropdownExitTimer = window.setTimeout(() => this._finishDropdownExit(), duration + 34);
7523
+ }
7524
+ /** CSS animations may be disabled or customized by consumers; never wait forever. */
7525
+ _getDropdownExitDurationMs() {
7526
+ if (window.matchMedia?.('(prefers-reduced-motion: reduce)').matches)
7527
+ return 0;
7528
+ const style = getComputedStyle(this._dropdown);
7529
+ const names = style.animationName.split(',').map((value) => value.trim());
7530
+ if (!names.length || names.every((name) => !name || name === 'none'))
7531
+ return 0;
7532
+ const toMs = (value) => {
7533
+ const trimmed = value.trim();
7534
+ const parsed = Number.parseFloat(trimmed);
7535
+ if (!Number.isFinite(parsed))
7536
+ return 0;
7537
+ return trimmed.endsWith('ms') ? parsed : trimmed.endsWith('s') ? parsed * 1000 : 0;
7538
+ };
7539
+ const durations = style.animationDuration.split(',');
7540
+ const delays = style.animationDelay.split(',');
7541
+ const counts = style.animationIterationCount.split(',');
7542
+ const maximum = names.reduce((max, name, index) => {
7543
+ if (!name || name === 'none')
7544
+ return max;
7545
+ const duration = toMs(durations[index % durations.length] ?? '0s');
7546
+ const delay = toMs(delays[index % delays.length] ?? '0s');
7547
+ const count = Number.parseFloat(counts[index % counts.length] ?? '1');
7548
+ const iterations = Number.isFinite(count) ? Math.max(0, count) : 1;
7549
+ return Math.max(max, Math.max(0, duration * iterations + delay));
7550
+ }, 0);
7551
+ return Math.min(maximum, 10000);
7552
+ }
7405
7553
  _updateDropdownVisibility() {
7406
7554
  if (this._state.isOpen) {
7407
7555
  this.setAttribute('data-open', 'true');
@@ -8277,6 +8425,8 @@ class EnhancedSelect extends HTMLElement {
8277
8425
  }
8278
8426
  }
8279
8427
  _setBusy(busy) {
8428
+ if (busy)
8429
+ this._beginBusyPresentation();
8280
8430
  this._state.isBusy = busy;
8281
8431
  this._syncListboxAccessibility();
8282
8432
  // Trigger re-render to show/hide busy indicator
@@ -9457,6 +9607,7 @@ class EnhancedSelect extends HTMLElement {
9457
9607
  _dispatchAcknowledgedActions(actions) {
9458
9608
  for (const action of actions) {
9459
9609
  if (action.type === 'cancel') {
9610
+ this._cancelBusyPresentation();
9460
9611
  this._dispatchAcknowledgedEvent('dataRequestCancel', action.notification);
9461
9612
  try {
9462
9613
  this._dataRequestCancelCallback?.(action.notification);
@@ -9481,6 +9632,7 @@ class EnhancedSelect extends HTMLElement {
9481
9632
  this._state.preserveScrollPosition = false;
9482
9633
  this._state.isSearching = true;
9483
9634
  }
9635
+ this._beginBusyPresentation();
9484
9636
  this._state.isBusy = true;
9485
9637
  this._acknowledgedLastRequest = request;
9486
9638
  this._syncListboxAccessibility();
@@ -9608,7 +9760,10 @@ class EnhancedSelect extends HTMLElement {
9608
9760
  throw new Error('Acknowledged snapshot render was superseded before completion');
9609
9761
  this._state.isBusy = snapshot.busy;
9610
9762
  if (!snapshot.busy) {
9611
- this._optionsContainer.querySelector('.busy-bucket')?.remove();
9763
+ this._syncBusyPresentation();
9764
+ if (!this._busyPresentationVisible) {
9765
+ this._optionsContainer.querySelector('.busy-bucket')?.remove();
9766
+ }
9612
9767
  if (this._shouldRenderLoadMoreTrigger())
9613
9768
  this._addLoadMoreTrigger();
9614
9769
  }
@@ -9926,7 +10081,166 @@ class EnhancedSelect extends HTMLElement {
9926
10081
  _refreshVirtualizationScope(filteredIndices) {
9927
10082
  this._virtualizationScope = this._deriveVirtualizationScope(filteredIndices);
9928
10083
  }
10084
+ _clearBusyPresentationHideTimer() {
10085
+ if (this._busyPresentationHideTimer === null)
10086
+ return;
10087
+ window.clearTimeout(this._busyPresentationHideTimer);
10088
+ this._lifecycleTimers.delete(this._busyPresentationHideTimer);
10089
+ this._busyPresentationHideTimer = null;
10090
+ }
10091
+ _beginBusyPresentation() {
10092
+ this._busyPresentationGeneration += 1;
10093
+ this._clearBusyPresentationHideTimer();
10094
+ this._busyPresentationVisible = this._config.busyBucket.enabled;
10095
+ this._busyPresentationStartedAt = this._busyBucket?.isConnected ? Date.now() : null;
10096
+ }
10097
+ _syncBusyPresentation() {
10098
+ if (!this._config.busyBucket.enabled) {
10099
+ this._cancelBusyPresentation();
10100
+ return;
10101
+ }
10102
+ if (this._state.isBusy) {
10103
+ if (!this._busyPresentationVisible || this._busyPresentationHideTimer !== null) {
10104
+ this._beginBusyPresentation();
10105
+ }
10106
+ return;
10107
+ }
10108
+ if (!this._busyPresentationVisible || this._busyPresentationHideTimer !== null)
10109
+ return;
10110
+ const configuredMinimum = Number(this._config.busyBucket.minDisplayTime ?? 0);
10111
+ const minimum = Number.isFinite(configuredMinimum) ? Math.max(0, configuredMinimum) : 0;
10112
+ if (this._busyPresentationStartedAt === null)
10113
+ this._busyPresentationStartedAt = Date.now();
10114
+ const shownAt = this._busyPresentationStartedAt;
10115
+ const remaining = minimum - Math.max(0, Date.now() - shownAt);
10116
+ if (remaining <= 0) {
10117
+ this._busyPresentationGeneration += 1;
10118
+ this._busyPresentationVisible = false;
10119
+ this._busyPresentationStartedAt = null;
10120
+ return;
10121
+ }
10122
+ const generation = this._busyPresentationGeneration;
10123
+ this._busyPresentationHideTimer = this._setLifecycleTimeout(() => {
10124
+ if (generation !== this._busyPresentationGeneration || this._state.isBusy)
10125
+ return;
10126
+ this._busyPresentationHideTimer = null;
10127
+ this._busyPresentationVisible = false;
10128
+ this._busyPresentationStartedAt = null;
10129
+ this._busyBucket = undefined;
10130
+ this._clearBusyBucketContentObserver();
10131
+ this._renderOptions();
10132
+ }, remaining);
10133
+ }
10134
+ _clearBusyBucketContentObserver() {
10135
+ this._busyBucketContentObserver?.disconnect();
10136
+ this._busyBucketContentObserver = undefined;
10137
+ }
10138
+ _cancelBusyPresentation() {
10139
+ this._busyPresentationGeneration += 1;
10140
+ this._clearBusyPresentationHideTimer();
10141
+ this._busyPresentationVisible = false;
10142
+ this._busyPresentationStartedAt = null;
10143
+ this._clearBusyBucketContentObserver();
10144
+ this._busyBucket = undefined;
10145
+ this._optionsContainer?.querySelector('.busy-bucket')?.remove();
10146
+ }
10147
+ _hasAccessibleBusyContent(nodes) {
10148
+ return nodes.some((node) => {
10149
+ if (node.nodeType === Node.TEXT_NODE)
10150
+ return Boolean(node.textContent?.trim());
10151
+ if (!(node instanceof Element))
10152
+ return false;
10153
+ if (node.hasAttribute('hidden')
10154
+ || node.hasAttribute('inert')
10155
+ || node.getAttribute('aria-hidden')?.toLowerCase() === 'true')
10156
+ return false;
10157
+ if (['aria-label', 'aria-labelledby', 'alt', 'title'].some((name) => Boolean(node.getAttribute(name)?.trim()))) {
10158
+ return true;
10159
+ }
10160
+ return this._hasAccessibleBusyContent(Array.from(node.childNodes));
10161
+ });
10162
+ }
10163
+ _syncBusyBucketContent(bucket) {
10164
+ if (bucket !== this._busyBucket)
10165
+ return;
10166
+ const contentSlot = bucket.querySelector('slot[name="loading-content"]');
10167
+ const iconSlot = bucket.querySelector('slot[name="loading-icon"]');
10168
+ if (!contentSlot || !iconSlot)
10169
+ return;
10170
+ const contentNodes = contentSlot.assignedNodes({ flatten: true });
10171
+ const iconNodes = iconSlot.assignedNodes({ flatten: true });
10172
+ const hasContent = contentNodes.length > 0;
10173
+ const hasAccessibleContent = this._hasAccessibleBusyContent(contentNodes);
10174
+ const icon = bucket.querySelector('.busy-icon');
10175
+ icon?.toggleAttribute('hidden', this._config.busyBucket.showSpinner === false && iconNodes.length === 0);
10176
+ const content = bucket.querySelector('.busy-content');
10177
+ content?.toggleAttribute('hidden', !hasContent);
10178
+ bucket.classList.toggle('busy-bucket--replace', this._config.busyBucket.contentMode === 'replace' && hasAccessibleContent);
10179
+ const message = bucket.querySelector('.busy-message');
10180
+ if (message) {
10181
+ const needsAccessibleFallback = this._config.busyBucket.contentMode === 'replace' && !hasAccessibleContent;
10182
+ message.toggleAttribute('hidden', this._config.busyBucket.showMessage === false && !needsAccessibleFallback);
10183
+ if (needsAccessibleFallback && !message.textContent?.trim()) {
10184
+ message.textContent = this._config.busyBucket.message || 'Loading...';
10185
+ }
10186
+ }
10187
+ }
10188
+ _createBusyBucket() {
10189
+ const bucket = document.createElement('div');
10190
+ bucket.setAttribute('part', 'loading');
10191
+ bucket.className = 'busy-bucket';
10192
+ this._busyBucket = bucket;
10193
+ const icon = document.createElement('div');
10194
+ icon.className = 'busy-icon';
10195
+ icon.setAttribute('part', 'loading-icon');
10196
+ icon.setAttribute('aria-hidden', 'true');
10197
+ const iconSlot = document.createElement('slot');
10198
+ iconSlot.name = 'loading-icon';
10199
+ if (this._config.busyBucket.showSpinner !== false) {
10200
+ const spinner = document.createElement('div');
10201
+ spinner.className = 'spinner';
10202
+ spinner.setAttribute('part', 'loading-spinner');
10203
+ spinner.setAttribute('aria-hidden', 'true');
10204
+ iconSlot.appendChild(spinner);
10205
+ }
10206
+ icon.appendChild(iconSlot);
10207
+ bucket.appendChild(icon);
10208
+ const message = document.createElement('div');
10209
+ message.className = 'busy-message';
10210
+ message.setAttribute('part', 'loading-message');
10211
+ message.textContent = this._config.busyBucket.message ?? 'Loading...';
10212
+ message.toggleAttribute('hidden', this._config.busyBucket.showMessage === false);
10213
+ bucket.appendChild(message);
10214
+ const content = document.createElement('div');
10215
+ content.className = 'busy-content';
10216
+ content.setAttribute('part', 'loading-content');
10217
+ const contentSlot = document.createElement('slot');
10218
+ contentSlot.name = 'loading-content';
10219
+ content.appendChild(contentSlot);
10220
+ bucket.appendChild(content);
10221
+ const syncContent = () => this._syncBusyBucketContent(bucket);
10222
+ contentSlot.addEventListener('slotchange', syncContent);
10223
+ iconSlot.addEventListener('slotchange', syncContent);
10224
+ syncContent();
10225
+ if (typeof MutationObserver !== 'undefined') {
10226
+ this._clearBusyBucketContentObserver();
10227
+ this._busyBucketContentObserver = new MutationObserver(syncContent);
10228
+ this._busyBucketContentObserver.observe(this, { childList: true, subtree: true, characterData: true });
10229
+ }
10230
+ return bucket;
10231
+ }
10232
+ _appendBusyBucket() {
10233
+ const bucket = this._createBusyBucket();
10234
+ this._optionsContainer.appendChild(bucket);
10235
+ if (this._busyPresentationStartedAt === null)
10236
+ this._busyPresentationStartedAt = Date.now();
10237
+ this._syncBusyBucketContent(bucket);
10238
+ return bucket;
10239
+ }
9929
10240
  _renderOptions() {
10241
+ this._syncBusyPresentation();
10242
+ this._clearBusyBucketContentObserver();
10243
+ this._busyBucket = undefined;
9930
10244
  this._ensureRegistryCurrent();
9931
10245
  const scrollTopBeforeRender = this._optionsContainer.scrollTop;
9932
10246
  this._renderCycleId += 1;
@@ -10115,11 +10429,20 @@ class EnhancedSelect extends HTMLElement {
10115
10429
  this._renderSingleOption(item, itemIndex, getValue, getLabel, fragment);
10116
10430
  }
10117
10431
  const renderedTargets = Array.from(fragment.children);
10118
- this._optionsContainer.appendChild(fragment);
10432
+ const existingBusyBucket = this._optionsContainer.querySelector('.busy-bucket');
10433
+ if (existingBusyBucket)
10434
+ this._optionsContainer.insertBefore(fragment, existingBusyBucket);
10435
+ else
10436
+ this._optionsContainer.appendChild(fragment);
10119
10437
  this._appendMountedVirtualizationTargets(renderedTargets);
10120
10438
  this._syncRenderedOptionAccessibility();
10121
10439
  this._syncLegacyActiveAria();
10122
10440
  if (cursor < filteredIndices.length) {
10441
+ if (this._busyPresentationVisible
10442
+ && this._config.busyBucket.enabled
10443
+ && !this._optionsContainer.querySelector('.busy-bucket')) {
10444
+ this._appendBusyBucket();
10445
+ }
10123
10446
  this._requestLifecycleFrame(renderChunk);
10124
10447
  }
10125
10448
  else {
@@ -10145,25 +10468,12 @@ class EnhancedSelect extends HTMLElement {
10145
10468
  this._appendGuardedBottomSpacer();
10146
10469
  }
10147
10470
  this._refreshMountedVirtualizationScope();
10148
- // Append Busy Indicator if busy
10149
- if (this._state.isBusy && this._config.busyBucket.enabled) {
10150
- const busyBucket = document.createElement('div');
10151
- busyBucket.setAttribute('part', 'loading');
10152
- busyBucket.className = 'busy-bucket';
10153
- if (this._config.busyBucket.showSpinner) {
10154
- const spinner = document.createElement('div');
10155
- spinner.className = 'spinner';
10156
- busyBucket.appendChild(spinner);
10157
- }
10158
- if (this._config.busyBucket.message) {
10159
- const message = document.createElement('div');
10160
- message.textContent = this._config.busyBucket.message;
10161
- busyBucket.appendChild(message);
10162
- }
10163
- this._optionsContainer.appendChild(busyBucket);
10164
- }
10165
- // Append Load More Trigger (Button or Sentinel) if enabled and not busy
10166
- else if ((!this._dataRequestCoordinator || !this._state.isBusy) && this._shouldRenderLoadMoreTrigger()) {
10471
+ if (this._busyPresentationVisible && this._config.busyBucket.enabled) {
10472
+ this._appendBusyBucket();
10473
+ }
10474
+ // The load-more trigger follows logical busy state, not any optional
10475
+ // visual minimum-display hold after a request has already completed.
10476
+ if ((!this._dataRequestCoordinator || !this._state.isBusy) && this._shouldRenderLoadMoreTrigger()) {
10167
10477
  this._addLoadMoreTrigger();
10168
10478
  }
10169
10479
  // Rebuilding the list temporarily removes its spacer geometry. Browsers