@aurodesignsystem/auro-library 5.11.1 → 5.11.3
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 +16 -0
- package/package.json +1 -1
- package/scripts/runtime/floatingUI.mjs +26 -14
- package/scripts/runtime/floatingUI.test.js +102 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Semantic Release Automated Changelog
|
|
2
2
|
|
|
3
|
+
## [5.11.3](https://github.com/AlaskaAirlines/auro-library/compare/v5.11.2...v5.11.3) (2026-03-31)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* correct focus local check for shadow DOM ([e713cfc](https://github.com/AlaskaAirlines/auro-library/commit/e713cfc07f1be4809c97e05af97b89050478e988))
|
|
9
|
+
|
|
10
|
+
## [5.11.2](https://github.com/AlaskaAirlines/auro-library/compare/v5.11.1...v5.11.2) (2026-03-17)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* prevent dropdown from closing on click for noToggle elements AB[#1494298](https://github.com/AlaskaAirlines/auro-library/issues/1494298) ([4d23b40](https://github.com/AlaskaAirlines/auro-library/commit/4d23b4082c8e22d9a865ba51b702f70185cfd455))
|
|
16
|
+
* return comment ([d2b315c](https://github.com/AlaskaAirlines/auro-library/commit/d2b315c0ca08d724ac6239d0e25b6127173f990e))
|
|
17
|
+
* simplify hideBib logic with early returns for readability ([bd4038d](https://github.com/AlaskaAirlines/auro-library/commit/bd4038dce05969e18e87910a234344f95c729ac2))
|
|
18
|
+
|
|
3
19
|
## [5.11.1](https://github.com/AlaskaAirlines/auro-library/compare/v5.11.0...v5.11.1) (2026-03-04)
|
|
4
20
|
|
|
5
21
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aurodesignsystem/auro-library",
|
|
3
|
-
"version": "5.11.
|
|
3
|
+
"version": "5.11.3",
|
|
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",
|
|
@@ -331,11 +331,10 @@ export default class AuroFloatingUI {
|
|
|
331
331
|
return;
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
-
const { activeElement } = document;
|
|
335
334
|
// if focus is still inside of trigger or bib, do not close
|
|
336
335
|
if (
|
|
337
|
-
this.element.
|
|
338
|
-
this.element.
|
|
336
|
+
this.element.matches(":focus") ||
|
|
337
|
+
this.element.matches(":focus-within")
|
|
339
338
|
) {
|
|
340
339
|
return;
|
|
341
340
|
}
|
|
@@ -488,19 +487,32 @@ export default class AuroFloatingUI {
|
|
|
488
487
|
* @param {String} eventType - The event type that triggered the hiding action.
|
|
489
488
|
*/
|
|
490
489
|
hideBib(eventType = "unknown") {
|
|
491
|
-
if (
|
|
492
|
-
|
|
493
|
-
|
|
490
|
+
if (this.element.disabled) {
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
494
493
|
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
this.showing = false;
|
|
501
|
-
this.dispatchEventDropdownToggle(eventType);
|
|
502
|
-
}
|
|
494
|
+
// noToggle dropdowns should not close when the trigger is clicked (the
|
|
495
|
+
// "toggle" behavior), but they CAN still close via other interactions like
|
|
496
|
+
// Escape key or focus loss.
|
|
497
|
+
if (this.element.noToggle && eventType === "click") {
|
|
498
|
+
return;
|
|
503
499
|
}
|
|
500
|
+
|
|
501
|
+
this.lockScroll(false);
|
|
502
|
+
this.element.triggerChevron?.removeAttribute("data-expanded");
|
|
503
|
+
|
|
504
|
+
if (this.element.isPopoverVisible) {
|
|
505
|
+
this.element.isPopoverVisible = false;
|
|
506
|
+
}
|
|
507
|
+
if (this.showing) {
|
|
508
|
+
this.cleanupHideHandlers();
|
|
509
|
+
this.showing = false;
|
|
510
|
+
this.dispatchEventDropdownToggle(eventType);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// Only clear the global reference if the bib was actually hidden.
|
|
514
|
+
// Clearing it when hideBib is blocked (e.g. noToggle + click) corrupts
|
|
515
|
+
// the singleton state so other dropdowns can't detect this one is still open.
|
|
504
516
|
document.expandedAuroFloater = null;
|
|
505
517
|
}
|
|
506
518
|
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { expect } from "@open-wc/testing";
|
|
2
|
+
import sinon from "sinon";
|
|
3
|
+
import AuroFloatingUI from "./floatingUI.mjs";
|
|
4
|
+
|
|
5
|
+
describe("AuroFloatingUI", () => {
|
|
6
|
+
let host;
|
|
7
|
+
let bib;
|
|
8
|
+
let floatingUI;
|
|
9
|
+
let hideBibSpy;
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
host = document.createElement("div");
|
|
13
|
+
bib = document.createElement("div");
|
|
14
|
+
host.bib = bib;
|
|
15
|
+
host.triggerChevron = document.createElement("span");
|
|
16
|
+
|
|
17
|
+
document.body.append(host, bib);
|
|
18
|
+
|
|
19
|
+
AuroFloatingUI.isMousePressed = false;
|
|
20
|
+
floatingUI = new AuroFloatingUI(host, "dropdown");
|
|
21
|
+
hideBibSpy = sinon.spy(floatingUI, "hideBib");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
sinon.restore();
|
|
26
|
+
AuroFloatingUI.isMousePressed = false;
|
|
27
|
+
host?.remove();
|
|
28
|
+
bib?.remove();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("does not hide when the host matches focus-within", () => {
|
|
32
|
+
const checkedSelectors = [];
|
|
33
|
+
|
|
34
|
+
sinon.stub(host, "matches").callsFake((selector) => {
|
|
35
|
+
checkedSelectors.push(selector);
|
|
36
|
+
|
|
37
|
+
if (selector === ":focus") {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (selector === ":focus-within") {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return false;
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
floatingUI.handleFocusLoss();
|
|
49
|
+
|
|
50
|
+
expect(checkedSelectors).to.deep.equal([":focus", ":focus-within"]);
|
|
51
|
+
expect(hideBibSpy.called).to.be.false;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("does not hide when the host matches focus", () => {
|
|
55
|
+
const checkedSelectors = [];
|
|
56
|
+
|
|
57
|
+
sinon.stub(host, "matches").callsFake((selector) => {
|
|
58
|
+
checkedSelectors.push(selector);
|
|
59
|
+
|
|
60
|
+
if (selector === ":focus") {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return false;
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
floatingUI.handleFocusLoss();
|
|
68
|
+
|
|
69
|
+
expect(checkedSelectors).to.deep.equal([":focus"]);
|
|
70
|
+
expect(hideBibSpy.called).to.be.false;
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("does not hide when the bib is fullscreen", () => {
|
|
74
|
+
const checkedSelectors = [];
|
|
75
|
+
|
|
76
|
+
bib.setAttribute("isfullscreen", "");
|
|
77
|
+
|
|
78
|
+
sinon.stub(host, "matches").callsFake((selector) => {
|
|
79
|
+
checkedSelectors.push(selector);
|
|
80
|
+
return false;
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
floatingUI.handleFocusLoss();
|
|
84
|
+
|
|
85
|
+
expect(checkedSelectors).to.deep.equal([":focus", ":focus-within"]);
|
|
86
|
+
expect(hideBibSpy.called).to.be.false;
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("hides with a keydown event when the host no longer has focus", () => {
|
|
90
|
+
const checkedSelectors = [];
|
|
91
|
+
|
|
92
|
+
sinon.stub(host, "matches").callsFake((selector) => {
|
|
93
|
+
checkedSelectors.push(selector);
|
|
94
|
+
return false;
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
floatingUI.handleFocusLoss();
|
|
98
|
+
|
|
99
|
+
expect(checkedSelectors).to.deep.equal([":focus", ":focus-within"]);
|
|
100
|
+
expect(hideBibSpy.calledOnceWithExactly("keydown")).to.be.true;
|
|
101
|
+
});
|
|
102
|
+
});
|