@aurodesignsystem/auro-library 4.2.0 → 4.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Semantic Release Automated Changelog
2
2
 
3
+ ## [4.2.1](https://github.com/AlaskaAirlines/auro-library/compare/v4.2.0...v4.2.1) (2025-04-14)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * add SSR env condition check in floatingUI ([c71a77e](https://github.com/AlaskaAirlines/auro-library/commit/c71a77ed805dc2e61593dd0c483a01c9f19e2a01))
9
+ * correct method call to hide dropdown in AuroFloatingUI class ([44e30fc](https://github.com/AlaskaAirlines/auro-library/commit/44e30fc384be9adbcd3f493faba4c2f652c019f3))
10
+ * not to hide bib on blur event with mouse being pressed ([8808ee6](https://github.com/AlaskaAirlines/auro-library/commit/8808ee6911ccfb81c0e9a0ed23762852983e1239))
11
+ * remove bib on disconnect in floatingUI ([b5a2935](https://github.com/AlaskaAirlines/auro-library/commit/b5a29358910199589422067ad30767c99bb16daa))
12
+ * setup mousePressChecker in floatingUI's configure function ([6136d36](https://github.com/AlaskaAirlines/auro-library/commit/6136d36a980802dc56a0bea9d9aa12b7bf3e6621))
13
+
3
14
  # [4.2.0](https://github.com/AlaskaAirlines/auro-library/compare/v4.1.1...v4.2.0) (2025-04-10)
4
15
 
5
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aurodesignsystem/auro-library",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "description": "This repository holds shared scripts, utilities, and workflows utilized across repositories along the Auro Design System.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -6,6 +6,33 @@ import { autoUpdate, computePosition, offset, autoPlacement, flip } from '@float
6
6
  const MAX_CONFIGURATION_COUNT = 10;
7
7
 
8
8
  export default class AuroFloatingUI {
9
+
10
+ /**
11
+ * @private
12
+ */
13
+ static isMousePressed = false;
14
+
15
+ /**
16
+ * @private
17
+ */
18
+ static isMousePressHandlerInitialized = false;
19
+
20
+ /**
21
+ * @private
22
+ */
23
+ static setupMousePressChecker() {
24
+ if (!AuroFloatingUI.isMousePressHandlerInitialized && window && window.addEventListener) {
25
+ AuroFloatingUI.isMousePressHandlerInitialized = true;
26
+
27
+ const mouseEventGlobalHandler = (event) => {
28
+ AuroFloatingUI.isMousePressed = event.type === 'mousedown';
29
+ };
30
+
31
+ window.addEventListener('mousedown', mouseEventGlobalHandler);
32
+ window.addEventListener('mouseup', mouseEventGlobalHandler);
33
+ }
34
+ }
35
+
9
36
  constructor(element, behavior) {
10
37
  this.element = element;
11
38
  this.behavior = behavior;
@@ -197,7 +224,7 @@ export default class AuroFloatingUI {
197
224
 
198
225
  setTimeout(() => {
199
226
  this.configureBibStrategy(value);
200
- });
227
+ }, 0);
201
228
  }
202
229
 
203
230
  if (this.element.isPopoverVisible) {
@@ -244,6 +271,11 @@ export default class AuroFloatingUI {
244
271
  * If not, and if the bib isn't in fullscreen mode with focus lost, it hides the bib.
245
272
  */
246
273
  handleFocusLoss() {
274
+ // if mouse is being pressed, skip and let click event to handle the action
275
+ if (AuroFloatingUI.isMousePressed) {
276
+ return;
277
+ }
278
+
247
279
  if (this.element.noHideOnThisFocusLoss ||
248
280
  this.element.hasAttribute('noHideOnThisFocusLoss')) {
249
281
  return;
@@ -312,7 +344,7 @@ export default class AuroFloatingUI {
312
344
  // it conflicts if showBib gets call from a button that's not this.element.trigger
313
345
  setTimeout(() => {
314
346
  window.addEventListener('click', this.clickHandler);
315
- });
347
+ }, 0);
316
348
  }
317
349
 
318
350
  cleanupHideHandlers() {
@@ -461,8 +493,9 @@ export default class AuroFloatingUI {
461
493
  }
462
494
  break;
463
495
  case 'blur':
464
- // send this task to end of the queue to wait a frame in case focus moves within the floating element/bib
465
- setTimeout(() => this.handleFocusLoss());
496
+ // send this task 100ms later queue to
497
+ // wait a frame in case focus moves within the floating element/bib
498
+ setTimeout(() => this.handleFocusLoss(), 0);
466
499
  break;
467
500
  case 'click':
468
501
  if (document.activeElement === document.body) {
@@ -530,6 +563,8 @@ export default class AuroFloatingUI {
530
563
  }
531
564
 
532
565
  configure(elem, eventPrefix) {
566
+ AuroFloatingUI.setupMousePressChecker();
567
+
533
568
  this.eventPrefix = eventPrefix;
534
569
  if (this.element !== elem) {
535
570
  this.element = elem;
@@ -570,16 +605,22 @@ export default class AuroFloatingUI {
570
605
 
571
606
  disconnect() {
572
607
  this.cleanupHideHandlers();
573
- this.element.cleanup?.();
574
-
575
- // Remove event & keyboard listeners
576
- if (this.element?.trigger) {
577
- this.element.trigger.removeEventListener('keydown', this.handleEvent);
578
- this.element.trigger.removeEventListener('click', this.handleEvent);
579
- this.element.trigger.removeEventListener('mouseenter', this.handleEvent);
580
- this.element.trigger.removeEventListener('mouseleave', this.handleEvent);
581
- this.element.trigger.removeEventListener('focus', this.handleEvent);
582
- this.element.trigger.removeEventListener('blur', this.handleEvent);
608
+ if (this.element) {
609
+ this.element.cleanup?.();
610
+
611
+ if (this.element.bib) {
612
+ this.element.shadowRoot.append(this.element.bib);
613
+ }
614
+
615
+ // Remove event & keyboard listeners
616
+ if (this.element?.trigger) {
617
+ this.element.trigger.removeEventListener('keydown', this.handleEvent);
618
+ this.element.trigger.removeEventListener('click', this.handleEvent);
619
+ this.element.trigger.removeEventListener('mouseenter', this.handleEvent);
620
+ this.element.trigger.removeEventListener('mouseleave', this.handleEvent);
621
+ this.element.trigger.removeEventListener('focus', this.handleEvent);
622
+ this.element.trigger.removeEventListener('blur', this.handleEvent);
623
+ }
583
624
  }
584
625
  }
585
626
  }