@aurodesignsystem/auro-library 4.1.0-beta.1 → 4.1.0-beta.2
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 +8 -0
- package/package.json +1 -1
- package/scripts/runtime/floatingUI.mjs +28 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Semantic Release Automated Changelog
|
|
2
2
|
|
|
3
|
+
# [4.1.0-beta.2](https://github.com/AlaskaAirlines/auro-library/compare/v4.1.0-beta.1...v4.1.0-beta.2) (2025-04-01)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* hide bib correctly when losing focus on trigger ([226ed07](https://github.com/AlaskaAirlines/auro-library/commit/226ed07a6200d733649f6a9f6e651b88e6ce0d64))
|
|
9
|
+
* prevent clicking background of bib resetting `document.activeElement` ([b8c64d4](https://github.com/AlaskaAirlines/auro-library/commit/b8c64d494e42917c7aabbbc64addf3d7076c62c6))
|
|
10
|
+
|
|
3
11
|
# [4.1.0-beta.1](https://github.com/AlaskaAirlines/auro-library/compare/v4.0.0...v4.1.0-beta.1) (2025-03-28)
|
|
4
12
|
|
|
5
13
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aurodesignsystem/auro-library",
|
|
3
|
-
"version": "4.1.0-beta.
|
|
3
|
+
"version": "4.1.0-beta.2",
|
|
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",
|
|
@@ -235,6 +235,14 @@ export default class AuroFloatingUI {
|
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
+
/**
|
|
239
|
+
* @private
|
|
240
|
+
* getting called on 'blur' in trigger or `focusin` in document
|
|
241
|
+
*
|
|
242
|
+
* Hides the bib if focus moves outside of the trigger or bib, unless a 'noHideOnThisFocusLoss' flag is set.
|
|
243
|
+
* This method checks if the currently active element is still within the trigger or bib.
|
|
244
|
+
* If not, and if the bib isn't in fullscreen mode with focus lost, it hides the bib.
|
|
245
|
+
*/
|
|
238
246
|
handleFocusLoss() {
|
|
239
247
|
if (this.element.noHideOnThisFocusLoss ||
|
|
240
248
|
this.element.hasAttribute('noHideOnThisFocusLoss')) {
|
|
@@ -242,9 +250,12 @@ export default class AuroFloatingUI {
|
|
|
242
250
|
}
|
|
243
251
|
|
|
244
252
|
const { activeElement } = document;
|
|
245
|
-
if
|
|
246
|
-
|
|
247
|
-
|
|
253
|
+
// if focus is still inside of trigger or bib, do not close
|
|
254
|
+
if (this.element.contains(activeElement) || this.element.bib?.contains(activeElement)) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
// if fullscreen bib is still open and the focus is missing, do not close
|
|
258
|
+
if (this.element.bib.hasAttribute('isfullscreen') && activeElement === document.body) {
|
|
248
259
|
return;
|
|
249
260
|
}
|
|
250
261
|
|
|
@@ -252,6 +263,12 @@ export default class AuroFloatingUI {
|
|
|
252
263
|
}
|
|
253
264
|
|
|
254
265
|
setupHideHandlers() {
|
|
266
|
+
this.preventFocusLoseOnBibClick = (event) => {
|
|
267
|
+
event.preventDefault();
|
|
268
|
+
event.stopPropagation();
|
|
269
|
+
};
|
|
270
|
+
this.element.bib.addEventListener('mousedown', this.preventFocusLoseOnBibClick);
|
|
271
|
+
|
|
255
272
|
// Define handlers & store references
|
|
256
273
|
this.focusHandler = () => this.handleFocusLoss();
|
|
257
274
|
|
|
@@ -300,6 +317,12 @@ export default class AuroFloatingUI {
|
|
|
300
317
|
|
|
301
318
|
cleanupHideHandlers() {
|
|
302
319
|
// Remove event listeners if they exist
|
|
320
|
+
|
|
321
|
+
if (this.preventFocusLoseOnBibClick) {
|
|
322
|
+
this.element.bib.removeEventListener('mousedown', this.preventFocusLoseOnBibClick);
|
|
323
|
+
delete this.preventFocusLoseOnBibClick;
|
|
324
|
+
}
|
|
325
|
+
|
|
303
326
|
if (this.focusHandler) {
|
|
304
327
|
document.removeEventListener('focusin', this.focusHandler);
|
|
305
328
|
this.focusHandler = null;
|
|
@@ -438,7 +461,8 @@ export default class AuroFloatingUI {
|
|
|
438
461
|
}
|
|
439
462
|
break;
|
|
440
463
|
case 'blur':
|
|
441
|
-
this
|
|
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());
|
|
442
466
|
break;
|
|
443
467
|
case 'click':
|
|
444
468
|
if (document.activeElement === document.body) {
|