@atlaskit/top-layer 0.12.0 → 0.12.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 +15 -0
- package/dist/cjs/animations/presets.js +5 -5
- package/dist/cjs/dialog/create-close-event.js +1 -1
- package/dist/cjs/dialog/dialog-content.js +5 -5
- package/dist/cjs/entry-points/use-arrow-navigation.js +3 -2
- package/dist/cjs/internal/ensure-preset-styles.js +1 -1
- package/dist/cjs/internal/placement-to-position-area.js +43 -0
- package/dist/cjs/internal/placement-to-try-fallbacks.js +82 -0
- package/dist/cjs/internal/reduced-motion.js +1 -1
- package/dist/cjs/internal/resolve-placement.js +2 -2
- package/dist/cjs/internal/role-types.js +1 -1
- package/dist/cjs/internal/slot.js +3 -3
- package/dist/cjs/internal/use-anchor-position.js +33 -161
- package/dist/cjs/internal/use-animated-visibility.js +10 -10
- package/dist/cjs/internal/use-animation-preset.js +1 -1
- package/dist/cjs/internal/use-preset-styles.js +1 -1
- package/dist/cjs/internal/use-width-from-anchor.js +4 -4
- package/dist/cjs/popover/create-close-event.js +1 -1
- package/dist/cjs/popover/popover.js +3 -3
- package/dist/cjs/popup/popup-content.js +6 -6
- package/dist/cjs/popup/popup-context.js +2 -38
- package/dist/cjs/popup/popup-provider.js +15 -0
- package/dist/cjs/popup/popup-trigger-function.js +2 -2
- package/dist/cjs/popup/popup-trigger.js +2 -2
- package/dist/cjs/popup/popup.js +2 -2
- package/dist/cjs/popup/use-maybe-popup-context.js +17 -0
- package/dist/cjs/popup/use-popup-context.js +20 -0
- package/dist/cjs/testing/polyfill.js +8 -8
- package/dist/cjs/testing/to-be-visible.js +5 -5
- package/dist/cjs/use-arrow-navigation/index.js +3 -2
- package/dist/cjs/use-arrow-navigation/is-at-current-menu-level.js +94 -0
- package/dist/cjs/use-arrow-navigation/use-arrow-navigation.js +0 -82
- package/dist/cjs/use-simple-light-dismiss/index.js +3 -3
- package/dist/es2019/animations/presets.js +5 -5
- package/dist/es2019/dialog/create-close-event.js +1 -1
- package/dist/es2019/dialog/dialog-content.js +5 -5
- package/dist/es2019/entry-points/use-arrow-navigation.js +2 -1
- package/dist/es2019/internal/ensure-preset-styles.js +1 -1
- package/dist/es2019/internal/placement-to-position-area.js +40 -0
- package/dist/es2019/internal/placement-to-try-fallbacks.js +77 -0
- package/dist/es2019/internal/reduced-motion.js +1 -1
- package/dist/es2019/internal/resolve-placement.js +2 -2
- package/dist/es2019/internal/role-types.js +1 -1
- package/dist/es2019/internal/slot.js +3 -3
- package/dist/es2019/internal/use-anchor-position.js +15 -132
- package/dist/es2019/internal/use-animated-visibility.js +10 -10
- package/dist/es2019/internal/use-animation-preset.js +1 -1
- package/dist/es2019/internal/use-preset-styles.js +1 -1
- package/dist/es2019/internal/use-width-from-anchor.js +4 -4
- package/dist/es2019/popover/create-close-event.js +1 -1
- package/dist/es2019/popover/popover.js +3 -3
- package/dist/es2019/popup/popup-content.js +6 -5
- package/dist/es2019/popup/popup-context.js +2 -36
- package/dist/es2019/popup/popup-provider.js +10 -0
- package/dist/es2019/popup/popup-trigger-function.js +1 -1
- package/dist/es2019/popup/popup-trigger.js +2 -1
- package/dist/es2019/popup/popup.js +1 -1
- package/dist/es2019/popup/use-maybe-popup-context.js +12 -0
- package/dist/es2019/popup/use-popup-context.js +15 -0
- package/dist/es2019/testing/polyfill.js +8 -8
- package/dist/es2019/testing/to-be-visible.js +5 -5
- package/dist/es2019/use-arrow-navigation/index.js +2 -1
- package/dist/es2019/use-arrow-navigation/is-at-current-menu-level.js +88 -0
- package/dist/es2019/use-arrow-navigation/use-arrow-navigation.js +0 -81
- package/dist/es2019/use-simple-light-dismiss/index.js +3 -3
- package/dist/esm/animations/presets.js +5 -5
- package/dist/esm/dialog/create-close-event.js +1 -1
- package/dist/esm/dialog/dialog-content.js +5 -5
- package/dist/esm/entry-points/use-arrow-navigation.js +2 -1
- package/dist/esm/internal/ensure-preset-styles.js +1 -1
- package/dist/esm/internal/placement-to-position-area.js +38 -0
- package/dist/esm/internal/placement-to-try-fallbacks.js +76 -0
- package/dist/esm/internal/reduced-motion.js +1 -1
- package/dist/esm/internal/resolve-placement.js +2 -2
- package/dist/esm/internal/role-types.js +1 -1
- package/dist/esm/internal/slot.js +3 -3
- package/dist/esm/internal/use-anchor-position.js +31 -157
- package/dist/esm/internal/use-animated-visibility.js +10 -10
- package/dist/esm/internal/use-animation-preset.js +1 -1
- package/dist/esm/internal/use-preset-styles.js +1 -1
- package/dist/esm/internal/use-width-from-anchor.js +4 -4
- package/dist/esm/popover/create-close-event.js +1 -1
- package/dist/esm/popover/popover.js +3 -3
- package/dist/esm/popup/popup-content.js +6 -5
- package/dist/esm/popup/popup-context.js +2 -36
- package/dist/esm/popup/popup-provider.js +10 -0
- package/dist/esm/popup/popup-trigger-function.js +1 -1
- package/dist/esm/popup/popup-trigger.js +2 -1
- package/dist/esm/popup/popup.js +1 -1
- package/dist/esm/popup/use-maybe-popup-context.js +12 -0
- package/dist/esm/popup/use-popup-context.js +15 -0
- package/dist/esm/testing/polyfill.js +8 -8
- package/dist/esm/testing/to-be-visible.js +5 -5
- package/dist/esm/use-arrow-navigation/index.js +2 -1
- package/dist/esm/use-arrow-navigation/is-at-current-menu-level.js +88 -0
- package/dist/esm/use-arrow-navigation/use-arrow-navigation.js +0 -81
- package/dist/esm/use-simple-light-dismiss/index.js +3 -3
- package/dist/types/dialog/create-close-event.d.ts +1 -1
- package/dist/types/dialog/types.d.ts +8 -0
- package/dist/types/entry-points/use-arrow-navigation.d.ts +2 -1
- package/dist/types/internal/placement-to-position-area.d.ts +21 -0
- package/dist/types/internal/placement-to-try-fallbacks.d.ts +36 -0
- package/dist/types/internal/reduced-motion.d.ts +1 -1
- package/dist/types/internal/resolve-placement.d.ts +2 -2
- package/dist/types/internal/slot.d.ts +4 -4
- package/dist/types/internal/use-anchor-position.d.ts +0 -55
- package/dist/types/internal/use-animated-visibility.d.ts +3 -3
- package/dist/types/internal/use-animation-preset.d.ts +1 -1
- package/dist/types/internal/use-preset-styles.d.ts +1 -1
- package/dist/types/internal/use-width-from-anchor.d.ts +2 -2
- package/dist/types/popover/create-close-event.d.ts +1 -1
- package/dist/types/popover/popover.d.ts +1 -1
- package/dist/types/popup/popup-context.d.ts +2 -22
- package/dist/types/popup/popup-provider.d.ts +10 -0
- package/dist/types/popup/use-maybe-popup-context.d.ts +8 -0
- package/dist/types/popup/use-popup-context.d.ts +7 -0
- package/dist/types/testing/to-be-visible.d.ts +3 -3
- package/dist/types/use-arrow-navigation/index.d.ts +2 -1
- package/dist/types/use-arrow-navigation/is-at-current-menu-level.d.ts +48 -0
- package/dist/types/use-arrow-navigation/use-arrow-navigation.d.ts +0 -48
- package/dist/types/use-simple-light-dismiss/index.d.ts +1 -1
- package/dist/types-ts4.5/dialog/create-close-event.d.ts +1 -1
- package/dist/types-ts4.5/dialog/types.d.ts +8 -0
- package/dist/types-ts4.5/entry-points/use-arrow-navigation.d.ts +2 -1
- package/dist/types-ts4.5/internal/placement-to-position-area.d.ts +21 -0
- package/dist/types-ts4.5/internal/placement-to-try-fallbacks.d.ts +36 -0
- package/dist/types-ts4.5/internal/reduced-motion.d.ts +1 -1
- package/dist/types-ts4.5/internal/resolve-placement.d.ts +2 -2
- package/dist/types-ts4.5/internal/slot.d.ts +4 -4
- package/dist/types-ts4.5/internal/use-anchor-position.d.ts +0 -55
- package/dist/types-ts4.5/internal/use-animated-visibility.d.ts +3 -3
- package/dist/types-ts4.5/internal/use-animation-preset.d.ts +1 -1
- package/dist/types-ts4.5/internal/use-preset-styles.d.ts +1 -1
- package/dist/types-ts4.5/internal/use-width-from-anchor.d.ts +2 -2
- package/dist/types-ts4.5/popover/create-close-event.d.ts +1 -1
- package/dist/types-ts4.5/popover/popover.d.ts +1 -1
- package/dist/types-ts4.5/popup/popup-context.d.ts +2 -22
- package/dist/types-ts4.5/popup/popup-provider.d.ts +10 -0
- package/dist/types-ts4.5/popup/use-maybe-popup-context.d.ts +8 -0
- package/dist/types-ts4.5/popup/use-popup-context.d.ts +7 -0
- package/dist/types-ts4.5/testing/to-be-visible.d.ts +3 -3
- package/dist/types-ts4.5/use-arrow-navigation/index.d.ts +2 -1
- package/dist/types-ts4.5/use-arrow-navigation/is-at-current-menu-level.d.ts +48 -0
- package/dist/types-ts4.5/use-arrow-navigation/use-arrow-navigation.d.ts +0 -48
- package/dist/types-ts4.5/use-simple-light-dismiss/index.d.ts +1 -1
- package/package.json +2 -2
- package/dist/cjs/arrow/index.js +0 -131
- package/dist/cjs/arrow/types.js +0 -5
- package/dist/es2019/arrow/index.js +0 -269
- package/dist/es2019/arrow/types.js +0 -1
- package/dist/esm/arrow/index.js +0 -124
- package/dist/esm/arrow/types.js +0 -1
- package/dist/types/arrow/index.d.ts +0 -24
- package/dist/types/arrow/types.d.ts +0 -29
- package/dist/types-ts4.5/arrow/index.d.ts +0 -24
- package/dist/types-ts4.5/arrow/types.d.ts +0 -29
|
@@ -15,19 +15,19 @@ var _usePresetStyles = require("./use-preset-styles");
|
|
|
15
15
|
*
|
|
16
16
|
* Used by both `Popover` and `Dialog` to share the same animation lifecycle
|
|
17
17
|
* logic. Those components own their own show/hide mechanisms (showPopover /
|
|
18
|
-
* hidePopover vs showModal / close) and event handling
|
|
18
|
+
* hidePopover vs showModal / close) and event handling - this hook only
|
|
19
19
|
* manages the relationship between `isOpen` and when children are rendered.
|
|
20
20
|
*
|
|
21
21
|
* ## Problem
|
|
22
22
|
*
|
|
23
23
|
* We want to delay the unmount of children until a CSS exit transition has
|
|
24
24
|
* finished playing. If we unmount children the moment `isOpen` becomes
|
|
25
|
-
* `false`, the exit animation is never visible
|
|
25
|
+
* `false`, the exit animation is never visible - the content just disappears.
|
|
26
26
|
*
|
|
27
27
|
* ## How it works
|
|
28
28
|
*
|
|
29
29
|
* `showChildren` tracks whether the consumer's children should be in the DOM.
|
|
30
|
-
* It does not mirror `isOpen` exactly
|
|
30
|
+
* It does not mirror `isOpen` exactly - it intentionally lags behind during
|
|
31
31
|
* exit animations:
|
|
32
32
|
*
|
|
33
33
|
* ```
|
|
@@ -63,12 +63,12 @@ function useAnimatedVisibility(_ref) {
|
|
|
63
63
|
// or the user has enabled the "prefers reduced motion" OS setting.
|
|
64
64
|
var willAnimate = Boolean(animate) && !(0, _reducedMotion.prefersReducedMotion)();
|
|
65
65
|
|
|
66
|
-
//
|
|
66
|
+
// showChildren state
|
|
67
67
|
//
|
|
68
68
|
// This is the core of the hook. `showChildren` controls whether the
|
|
69
69
|
// consumer's children are in the DOM. The two `if` blocks below are
|
|
70
70
|
// intentionally written as synchronous state updates during render
|
|
71
|
-
// (React supports this pattern
|
|
71
|
+
// (React supports this pattern - setState during render is treated as
|
|
72
72
|
// a synchronous re-render before the browser paints).
|
|
73
73
|
//
|
|
74
74
|
// Mount path: isOpen went true but showChildren is still false → mount.
|
|
@@ -95,7 +95,7 @@ function useAnimatedVisibility(_ref) {
|
|
|
95
95
|
var onExitFinishRef = (0, _react.useRef)(onExitFinish);
|
|
96
96
|
onExitFinishRef.current = onExitFinish;
|
|
97
97
|
|
|
98
|
-
//
|
|
98
|
+
// Animated entry effect
|
|
99
99
|
//
|
|
100
100
|
// Fires `onEnterFinish` after the entry transition completes.
|
|
101
101
|
// When there is no animation, fires it immediately via a separate effect.
|
|
@@ -144,7 +144,7 @@ function useAnimatedVisibility(_ref) {
|
|
|
144
144
|
};
|
|
145
145
|
}, [isOpen, showChildren, willAnimate, preset === null || preset === void 0 ? void 0 : preset.enterDurationMs, elementRef]);
|
|
146
146
|
|
|
147
|
-
//
|
|
147
|
+
// Non-animated entry callback
|
|
148
148
|
//
|
|
149
149
|
// When there is no animation, fire `onEnterFinish` immediately on mount and after `isOpen` goes false->true.
|
|
150
150
|
// The initial value is false to make sure it fires on mount if the current `isOpen` is true.
|
|
@@ -158,7 +158,7 @@ function useAnimatedVisibility(_ref) {
|
|
|
158
158
|
}
|
|
159
159
|
}, [isOpen, willAnimate]);
|
|
160
160
|
|
|
161
|
-
//
|
|
161
|
+
// Animated exit effect
|
|
162
162
|
//
|
|
163
163
|
// Runs when all three conditions are true:
|
|
164
164
|
// • `isOpen` is false (consumer wants to close)
|
|
@@ -221,10 +221,10 @@ function useAnimatedVisibility(_ref) {
|
|
|
221
221
|
};
|
|
222
222
|
}, [isOpen, showChildren, willAnimate, preset === null || preset === void 0 ? void 0 : preset.exitDurationMs, elementRef]);
|
|
223
223
|
|
|
224
|
-
//
|
|
224
|
+
// Non-animated exit callback
|
|
225
225
|
//
|
|
226
226
|
// When there is no animation, children unmount synchronously (handled
|
|
227
|
-
// by the `if` block above). But `onExitFinish` still needs to fire
|
|
227
|
+
// by the `if` block above). But `onExitFinish` still needs to fire -
|
|
228
228
|
// we do that in a follow-up effect so the consumer can react to it.
|
|
229
229
|
//
|
|
230
230
|
// Uses a previous-value ref (`wasOpenRef`) to detect the exact
|
|
@@ -9,7 +9,7 @@ var _ensurePresetStyles = require("./ensure-preset-styles");
|
|
|
9
9
|
/**
|
|
10
10
|
* Normalizes the `animate` prop to a preset (or null) and ensures its CSS
|
|
11
11
|
* is injected once into document.head. Used by PopupContent, Popover, and
|
|
12
|
-
* DialogContent so they
|
|
12
|
+
* DialogContent so they do not duplicate this logic.
|
|
13
13
|
*/
|
|
14
14
|
function useAnimationPreset(animate) {
|
|
15
15
|
var preset = animate != null && animate !== false ? animate : null;
|
|
@@ -10,7 +10,7 @@ var _ensurePresetStyles = require("./ensure-preset-styles");
|
|
|
10
10
|
* Normalizes a preset prop to a value (or null) and ensures its CSS
|
|
11
11
|
* is injected once into `document.head`.
|
|
12
12
|
*
|
|
13
|
-
* Works with any preset that has `{ css, name }`
|
|
13
|
+
* Works with any preset that has `{ css, name }` - animation presets
|
|
14
14
|
* (TAnimationPreset) satisfies this shape.
|
|
15
15
|
*/
|
|
16
16
|
function usePresetStyles(_ref) {
|
|
@@ -9,8 +9,8 @@ var _setStyle = require("./set-style");
|
|
|
9
9
|
/**
|
|
10
10
|
* Sets the width of a popover element relative to its anchor element.
|
|
11
11
|
*
|
|
12
|
-
* - `'match-anchor'` → `width: anchor-size(width)`
|
|
13
|
-
* - `'min-anchor'` → `min-width: anchor-size(width)`
|
|
12
|
+
* - `'match-anchor'` → `width: anchor-size(width)` - popover matches anchor width exactly.
|
|
13
|
+
* - `'min-anchor'` → `min-width: anchor-size(width)` - popover is at least as wide as anchor,
|
|
14
14
|
* but can grow wider.
|
|
15
15
|
* - `'none'` → no explicit width is set (default behaviour)
|
|
16
16
|
*
|
|
@@ -35,7 +35,7 @@ function useWidthFromAnchor(_ref) {
|
|
|
35
35
|
var supportsAnchorSize = typeof CSS !== 'undefined' && typeof CSS.supports === 'function' && CSS.supports('width', 'anchor-size(width)');
|
|
36
36
|
if (mode === 'match-anchor') {
|
|
37
37
|
// Set an exact width matching the anchor.
|
|
38
|
-
// `min-inline-size` is intentionally NOT set here
|
|
38
|
+
// `min-inline-size` is intentionally NOT set here - it would override the
|
|
39
39
|
// explicit width constraint, allowing the popover to grow past the anchor's width.
|
|
40
40
|
if (supportsAnchorSize) {
|
|
41
41
|
return (0, _setStyle.setStyle)({
|
|
@@ -91,7 +91,7 @@ function useWidthFromAnchor(_ref) {
|
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
// No anchor available in JS fallback
|
|
94
|
+
// No anchor available in JS fallback - still apply min-inline-size.
|
|
95
95
|
return (0, _setStyle.setStyle)({
|
|
96
96
|
el: node,
|
|
97
97
|
styles: [minInlineSizeStyle]
|
|
@@ -8,7 +8,7 @@ exports.createPopoverCloseEvent = createPopoverCloseEvent;
|
|
|
8
8
|
* Creates a synthetic DOM event from a `TPopoverCloseReason`.
|
|
9
9
|
*
|
|
10
10
|
* Useful when bridging the Popover primitive's `onClose({ reason })` callback
|
|
11
|
-
* to a legacy API that expects a native DOM event
|
|
11
|
+
* to a legacy API that expects a native DOM event - for example,
|
|
12
12
|
* `@atlaskit/inline-dialog`'s `onClose(event)` contract.
|
|
13
13
|
*
|
|
14
14
|
* - `'escape'` → `KeyboardEvent('keydown', { key: 'Escape' })`
|
|
@@ -56,7 +56,7 @@ var POPUP_ROLES = new Set(['menu', 'listbox', 'dialog', 'alertdialog', 'tree', '
|
|
|
56
56
|
* Unopinionated top-layer primitive.
|
|
57
57
|
*
|
|
58
58
|
* Manages only visibility (isOpen) and animation (animate). Has no knowledge
|
|
59
|
-
* of positioning
|
|
59
|
+
* of positioning - compose with `useAnchorPosition` for anchor positioning
|
|
60
60
|
* and optionally `useWidthFromAnchor` for setting the width of a popover element
|
|
61
61
|
* relative to its anchor trigger.
|
|
62
62
|
*
|
|
@@ -105,7 +105,7 @@ var Popover = exports.Popover = /*#__PURE__*/(0, _react.forwardRef)(function Pop
|
|
|
105
105
|
showChildren = _useAnimatedVisibilit.showChildren,
|
|
106
106
|
preset = _useAnimatedVisibilit.preset;
|
|
107
107
|
|
|
108
|
-
//
|
|
108
|
+
// Focus management
|
|
109
109
|
// Initial focus: on open, moves focus into the popover (role-dependent).
|
|
110
110
|
// Focus wrap: Tab/Shift+Tab cycle within the popover for dialog roles.
|
|
111
111
|
// Focus restoration: handled natively by the Popover API. The browser
|
|
@@ -121,7 +121,7 @@ var Popover = exports.Popover = /*#__PURE__*/(0, _react.forwardRef)(function Pop
|
|
|
121
121
|
role: role
|
|
122
122
|
});
|
|
123
123
|
|
|
124
|
-
//
|
|
124
|
+
// Open layer observer registration
|
|
125
125
|
// Notifies the open layer observer so app-coordination features
|
|
126
126
|
// (closeLayers(), open-count subscriptions) work with top-layer popovers.
|
|
127
127
|
//
|
|
@@ -16,7 +16,7 @@ var _roleTypes = require("../internal/role-types");
|
|
|
16
16
|
var _useAnchorPosition = require("../internal/use-anchor-position");
|
|
17
17
|
var _useWidthFromAnchor = require("../internal/use-width-from-anchor");
|
|
18
18
|
var _popover = require("../popover/popover");
|
|
19
|
-
var
|
|
19
|
+
var _useMaybePopupContext = require("./use-maybe-popup-context");
|
|
20
20
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
21
21
|
/**
|
|
22
22
|
* Thin context wrapper that composes `Popover` + `useAnchorPosition`.
|
|
@@ -46,7 +46,7 @@ var PopupContent = exports.PopupContent = /*#__PURE__*/(0, _react.forwardRef)(fu
|
|
|
46
46
|
onEnterFinish = _ref.onEnterFinish,
|
|
47
47
|
onExitFinish = _ref.onExitFinish;
|
|
48
48
|
// When inside <Popup>, context provides defaults. Props always win.
|
|
49
|
-
var ctx = (0,
|
|
49
|
+
var ctx = (0, _useMaybePopupContext.useMaybePopupContext)();
|
|
50
50
|
var triggerRef = triggerRefProp !== null && triggerRefProp !== void 0 ? triggerRefProp : ctx === null || ctx === void 0 ? void 0 : ctx.triggerRef;
|
|
51
51
|
var placement = (_ref2 = placementProp !== null && placementProp !== void 0 ? placementProp : ctx === null || ctx === void 0 ? void 0 : ctx.placement) !== null && _ref2 !== void 0 ? _ref2 : {};
|
|
52
52
|
var onClose = onCloseProp !== null && onCloseProp !== void 0 ? onCloseProp : ctx === null || ctx === void 0 ? void 0 : ctx.onClose;
|
|
@@ -97,7 +97,7 @@ var PopupContent = exports.PopupContent = /*#__PURE__*/(0, _react.forwardRef)(fu
|
|
|
97
97
|
// Note: onOpenChange composition is handled by handleOpenChange below,
|
|
98
98
|
// which also adds nested-popover focus restoration.
|
|
99
99
|
|
|
100
|
-
//
|
|
100
|
+
// Sync aria-haspopup on the trigger with the content's role
|
|
101
101
|
var setAriaHasPopup = ctx === null || ctx === void 0 ? void 0 : ctx.setAriaHasPopup;
|
|
102
102
|
(0, _react.useLayoutEffect)(function () {
|
|
103
103
|
setAriaHasPopup === null || setAriaHasPopup === void 0 || setAriaHasPopup((0, _roleTypes.roleToAriaHasPopup)({
|
|
@@ -105,7 +105,7 @@ var PopupContent = exports.PopupContent = /*#__PURE__*/(0, _react.forwardRef)(fu
|
|
|
105
105
|
}));
|
|
106
106
|
}, [role, setAriaHasPopup]);
|
|
107
107
|
|
|
108
|
-
//
|
|
108
|
+
// Focus restoration
|
|
109
109
|
// The native Popover API handles focus restoration automatically for
|
|
110
110
|
// popover="auto" and popover="hint":
|
|
111
111
|
// - Escape → restores focus to the previously focused element (the trigger)
|
|
@@ -132,7 +132,7 @@ var PopupContent = exports.PopupContent = /*#__PURE__*/(0, _react.forwardRef)(fu
|
|
|
132
132
|
}
|
|
133
133
|
consumerOnOpenChange === null || consumerOnOpenChange === void 0 || consumerOnOpenChange(args);
|
|
134
134
|
|
|
135
|
-
//
|
|
135
|
+
// Nested popover focus restoration fallback
|
|
136
136
|
// The browser only captures `previouslyFocusedElement` for the
|
|
137
137
|
// outermost popover="auto" in the stack. Inner (nested) popovers
|
|
138
138
|
// have shouldRestoreFocus=false, so the browser will not restore
|
|
@@ -161,7 +161,7 @@ var PopupContent = exports.PopupContent = /*#__PURE__*/(0, _react.forwardRef)(fu
|
|
|
161
161
|
}
|
|
162
162
|
}, [consumerOnOpenChange, triggerRef, role, setPopupState, willAnimate]);
|
|
163
163
|
|
|
164
|
-
//
|
|
164
|
+
// Anchor positioning
|
|
165
165
|
// Compose useAnchorPosition with Popover. The hook positions the popover
|
|
166
166
|
// relative to the trigger element via CSS Anchor Positioning (with JS fallback).
|
|
167
167
|
// Use ctx.popoverRef when inside the compound (so the trigger can also
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
exports.useMaybePopupContext = useMaybePopupContext;
|
|
8
|
-
exports.usePopupContext = usePopupContext;
|
|
6
|
+
exports.PopupContext = void 0;
|
|
9
7
|
var _react = require("react");
|
|
10
8
|
/**
|
|
11
9
|
* Represents the lifecycle state of the popup.
|
|
@@ -24,38 +22,4 @@ var _react = require("react");
|
|
|
24
22
|
* the trigger (and thus the popup anchor) mid-animation.
|
|
25
23
|
*/
|
|
26
24
|
|
|
27
|
-
var PopupContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* __Popup provider__
|
|
31
|
-
*
|
|
32
|
-
* Provides shared popup state (placement, popoverId, triggerRef,
|
|
33
|
-
* isOpen, onClose) to compound child components such as `Popup.Trigger` and
|
|
34
|
-
* `Popup.Content`.
|
|
35
|
-
*/
|
|
36
|
-
var PopupProvider = exports.PopupProvider = PopupContext.Provider;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Returns the nearest `Popup` context value.
|
|
40
|
-
*
|
|
41
|
-
* Throws if called outside of a `<Popup>` compound component.
|
|
42
|
-
*/
|
|
43
|
-
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
44
|
-
function usePopupContext() {
|
|
45
|
-
var ctx = (0, _react.useContext)(PopupContext);
|
|
46
|
-
if (ctx === null) {
|
|
47
|
-
throw new Error('@atlaskit/top-layer: Popup compound components must be used within <Popup>.');
|
|
48
|
-
}
|
|
49
|
-
return ctx;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Returns the popup context if available, or `null` when used outside `<Popup>`.
|
|
54
|
-
*
|
|
55
|
-
* Used by `PopupContent` to support standalone usage (e.g. tooltip)
|
|
56
|
-
* where values are passed as props instead of coming from a compound component.
|
|
57
|
-
*/
|
|
58
|
-
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
59
|
-
function useMaybePopupContext() {
|
|
60
|
-
return (0, _react.useContext)(PopupContext);
|
|
61
|
-
}
|
|
25
|
+
var PopupContext = exports.PopupContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PopupProvider = void 0;
|
|
7
|
+
var _popupContext = require("./popup-context");
|
|
8
|
+
/**
|
|
9
|
+
* __Popup provider__
|
|
10
|
+
*
|
|
11
|
+
* Provides shared popup state (placement, popoverId, triggerRef,
|
|
12
|
+
* isOpen, onClose) to compound child components such as `Popup.Trigger` and
|
|
13
|
+
* `Popup.Content`.
|
|
14
|
+
*/
|
|
15
|
+
var PopupProvider = exports.PopupProvider = _popupContext.PopupContext.Provider;
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.PopupTriggerFunction = PopupTriggerFunction;
|
|
7
7
|
var _react = require("react");
|
|
8
|
-
var
|
|
8
|
+
var _usePopupContext2 = require("./use-popup-context");
|
|
9
9
|
/**
|
|
10
10
|
* Props passed to the `TriggerFunction` render-prop child.
|
|
11
11
|
*/
|
|
@@ -42,7 +42,7 @@ var _popupContext = require("./popup-context");
|
|
|
42
42
|
*/
|
|
43
43
|
function PopupTriggerFunction(_ref) {
|
|
44
44
|
var children = _ref.children;
|
|
45
|
-
var _usePopupContext = (0,
|
|
45
|
+
var _usePopupContext = (0, _usePopupContext2.usePopupContext)(),
|
|
46
46
|
triggerRef = _usePopupContext.triggerRef,
|
|
47
47
|
popoverRef = _usePopupContext.popoverRef,
|
|
48
48
|
popoverId = _usePopupContext.popoverId,
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.PopupTrigger = PopupTrigger;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _slot = require("../internal/slot");
|
|
10
|
-
var
|
|
10
|
+
var _usePopupContext2 = require("./use-popup-context");
|
|
11
11
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
12
12
|
/**
|
|
13
13
|
* Wraps a single trigger element via `cloneElement`. Attaches aria
|
|
@@ -22,7 +22,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
22
22
|
*/
|
|
23
23
|
function PopupTrigger(_ref) {
|
|
24
24
|
var children = _ref.children;
|
|
25
|
-
var _usePopupContext = (0,
|
|
25
|
+
var _usePopupContext = (0, _usePopupContext2.usePopupContext)(),
|
|
26
26
|
triggerRef = _usePopupContext.triggerRef,
|
|
27
27
|
popoverRef = _usePopupContext.popoverRef,
|
|
28
28
|
popoverId = _usePopupContext.popoverId,
|
package/dist/cjs/popup/popup.js
CHANGED
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.PopupRoot = PopupRoot;
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
var
|
|
11
|
+
var _popupProvider = require("./popup-provider");
|
|
12
12
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
13
13
|
/**
|
|
14
14
|
* Popup compound: trigger + popover content.
|
|
@@ -75,7 +75,7 @@ function PopupRoot(props) {
|
|
|
75
75
|
testId: testId,
|
|
76
76
|
forceFallbackPositioning: forceFallbackPositioning
|
|
77
77
|
};
|
|
78
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
78
|
+
return /*#__PURE__*/_react.default.createElement(_popupProvider.PopupProvider, {
|
|
79
79
|
value: contextValue
|
|
80
80
|
}, children);
|
|
81
81
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useMaybePopupContext = useMaybePopupContext;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _popupContext = require("./popup-context");
|
|
9
|
+
/**
|
|
10
|
+
* Returns the popup context if available, or `null` when used outside `<Popup>`.
|
|
11
|
+
*
|
|
12
|
+
* Used by `PopupContent` to support standalone usage (e.g. tooltip)
|
|
13
|
+
* where values are passed as props instead of coming from a compound component.
|
|
14
|
+
*/
|
|
15
|
+
function useMaybePopupContext() {
|
|
16
|
+
return (0, _react.useContext)(_popupContext.PopupContext);
|
|
17
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.usePopupContext = usePopupContext;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _popupContext = require("./popup-context");
|
|
9
|
+
/**
|
|
10
|
+
* Returns the nearest `Popup` context value.
|
|
11
|
+
*
|
|
12
|
+
* Throws if called outside of a `<Popup>` compound component.
|
|
13
|
+
*/
|
|
14
|
+
function usePopupContext() {
|
|
15
|
+
var ctx = (0, _react.useContext)(_popupContext.PopupContext);
|
|
16
|
+
if (ctx === null) {
|
|
17
|
+
throw new Error('@atlaskit/top-layer: Popup compound components must be used within <Popup>.');
|
|
18
|
+
}
|
|
19
|
+
return ctx;
|
|
20
|
+
}
|
|
@@ -104,7 +104,7 @@ function createToggleScheduler() {
|
|
|
104
104
|
newState: newState
|
|
105
105
|
});
|
|
106
106
|
|
|
107
|
-
// Task queue (setTimeout)
|
|
107
|
+
// Task queue (setTimeout) - browser fires toggle after microtasks drain, not during
|
|
108
108
|
setTimeout(function () {
|
|
109
109
|
var entry = pending.get(element);
|
|
110
110
|
if (!entry) {
|
|
@@ -174,7 +174,7 @@ function createDialogToggleScheduler() {
|
|
|
174
174
|
};
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
//
|
|
177
|
+
// Popover API
|
|
178
178
|
// Spec: https://html.spec.whatwg.org/multipage/popover.html
|
|
179
179
|
|
|
180
180
|
// `popover` attribute valid values. Empty / "auto" -> "auto"; unknown -> "manual".
|
|
@@ -537,7 +537,7 @@ if (typeof HTMLElement !== 'undefined') {
|
|
|
537
537
|
if (isPopoverOpen({
|
|
538
538
|
element: this
|
|
539
539
|
})) {
|
|
540
|
-
return; // already showing
|
|
540
|
+
return; // already showing - no-op
|
|
541
541
|
}
|
|
542
542
|
|
|
543
543
|
// sync, cancelable on show only
|
|
@@ -717,7 +717,7 @@ if (typeof HTMLElement !== 'undefined') {
|
|
|
717
717
|
}
|
|
718
718
|
}
|
|
719
719
|
|
|
720
|
-
//
|
|
720
|
+
// HTMLDialogElement
|
|
721
721
|
// Spec: https://html.spec.whatwg.org/multipage/interactive-elements.html#the-dialog-element
|
|
722
722
|
|
|
723
723
|
if (typeof HTMLDialogElement !== 'undefined') {
|
|
@@ -732,7 +732,7 @@ if (typeof HTMLDialogElement !== 'undefined') {
|
|
|
732
732
|
}
|
|
733
733
|
if (this.hasAttribute('open')) {
|
|
734
734
|
if (this._isModal) {
|
|
735
|
-
return; // already modal
|
|
735
|
+
return; // already modal - no-op
|
|
736
736
|
}
|
|
737
737
|
throw new DOMException("Failed to execute 'showModal' on 'HTMLDialogElement': ".concat(describeElement({
|
|
738
738
|
element: this
|
|
@@ -756,7 +756,7 @@ if (typeof HTMLDialogElement !== 'undefined') {
|
|
|
756
756
|
}
|
|
757
757
|
if (typeof proto.show !== 'function') {
|
|
758
758
|
proto.show = function show() {
|
|
759
|
-
// Browser does not throw for disconnected elements on show
|
|
759
|
+
// Browser does not throw for disconnected elements on show - just no-op
|
|
760
760
|
if (!this.isConnected || this.hasAttribute('open')) {
|
|
761
761
|
return;
|
|
762
762
|
}
|
|
@@ -779,10 +779,10 @@ if (typeof HTMLDialogElement !== 'undefined') {
|
|
|
779
779
|
if (typeof proto.close !== 'function') {
|
|
780
780
|
proto.close = function close(returnValue) {
|
|
781
781
|
if (!this.hasAttribute('open')) {
|
|
782
|
-
return; // already closed
|
|
782
|
+
return; // already closed - no-op
|
|
783
783
|
}
|
|
784
784
|
|
|
785
|
-
// Sync beforetoggle (not cancelable)
|
|
785
|
+
// Sync beforetoggle (not cancelable) - matches browser behavior
|
|
786
786
|
fireToggleEvent({
|
|
787
787
|
element: this,
|
|
788
788
|
type: 'beforetoggle',
|
|
@@ -8,13 +8,13 @@ var _matchers = require("@testing-library/jest-dom/matchers");
|
|
|
8
8
|
*
|
|
9
9
|
* jest-dom's `toBeVisible()` does not know about the Popover API. In real
|
|
10
10
|
* browsers the UA stylesheet hides `[popover]` with `display: none`, but
|
|
11
|
-
* jsdom has no such stylesheet
|
|
11
|
+
* jsdom has no such stylesheet - so closed popovers incorrectly appear visible.
|
|
12
12
|
*
|
|
13
13
|
* Raw jest-dom results in jsdom:
|
|
14
14
|
*
|
|
15
|
-
* closed popover / child → true (WRONG
|
|
15
|
+
* closed popover / child → true (WRONG - should be false)
|
|
16
16
|
* open popover / child → true (correct)
|
|
17
|
-
* closed dialog / child → false (correct
|
|
17
|
+
* closed dialog / child → false (correct - jsdom natively hides <dialog>)
|
|
18
18
|
* open dialog / child → true (correct)
|
|
19
19
|
*
|
|
20
20
|
* We correct both false positives and false negatives:
|
|
@@ -65,7 +65,7 @@ expect.extend({
|
|
|
65
65
|
var originalResult = _matchers.toBeVisible.call(this, element);
|
|
66
66
|
var topLayerState = nearestTopLayerState(element);
|
|
67
67
|
if (originalResult.pass) {
|
|
68
|
-
// Original says visible
|
|
68
|
+
// Original says visible - override if nearest top-layer host is closed.
|
|
69
69
|
if (topLayerState === 'closed') {
|
|
70
70
|
return {
|
|
71
71
|
pass: false,
|
|
@@ -77,7 +77,7 @@ expect.extend({
|
|
|
77
77
|
return originalResult;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
// Original says not visible
|
|
80
|
+
// Original says not visible - override if nearest top-layer host is open.
|
|
81
81
|
// jsdom may hide [popover] elements even when they are logically open.
|
|
82
82
|
if (topLayerState === 'open') {
|
|
83
83
|
return {
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
Object.defineProperty(exports, "isAtCurrentMenuLevel", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function get() {
|
|
9
|
-
return
|
|
9
|
+
return _isAtCurrentMenuLevel.isAtCurrentMenuLevel;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "useArrowNavigation", {
|
|
@@ -15,4 +15,5 @@ Object.defineProperty(exports, "useArrowNavigation", {
|
|
|
15
15
|
return _useArrowNavigation.useArrowNavigation;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
var _useArrowNavigation = require("./use-arrow-navigation");
|
|
18
|
+
var _useArrowNavigation = require("./use-arrow-navigation");
|
|
19
|
+
var _isAtCurrentMenuLevel = require("./is-at-current-menu-level");
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isAtCurrentMenuLevel = isAtCurrentMenuLevel;
|
|
7
|
+
var menuScope = '[role="menu"]';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Recursively walks from `node` toward `container`, returning `true` when
|
|
11
|
+
* `container` is reached without crossing another `role="menu"` ancestor.
|
|
12
|
+
*
|
|
13
|
+
* Used by `isAtCurrentMenuLevel` (pattern 2) to determine if the
|
|
14
|
+
* `closestMenu` is owned by the wrapper container directly. Recursion
|
|
15
|
+
* avoids a mutable `let parent` walk and keeps the function body linear.
|
|
16
|
+
*/
|
|
17
|
+
function reachesContainerWithoutNestedMenu(node, container) {
|
|
18
|
+
if (!node || node === container) {
|
|
19
|
+
return node === container;
|
|
20
|
+
}
|
|
21
|
+
if (node.getAttribute('role') === 'menu') {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
return reachesContainerWithoutNestedMenu(node.parentElement, container);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Returns true if the element belongs to the current menu level of the
|
|
29
|
+
* container, i.e. it is NOT inside a nested `role="menu"` sub-container.
|
|
30
|
+
*
|
|
31
|
+
* Uses `element.closest('[role="menu"]')` to determine the nearest menu
|
|
32
|
+
* scope. If the nearest scope is the container's own `role="menu"` element,
|
|
33
|
+
* the element belongs to this level. If it is a different (nested) menu,
|
|
34
|
+
* the element belongs to a child level and should be excluded.
|
|
35
|
+
*
|
|
36
|
+
* Supports two container patterns:
|
|
37
|
+
*
|
|
38
|
+
* **1. Container has `role="menu"` directly** (preferred, used by avatar-group):
|
|
39
|
+
* ```
|
|
40
|
+
* <div ref={containerRef} role="menu">
|
|
41
|
+
* <button role="menuitem" /> ← isAtCurrentMenuLevel → true
|
|
42
|
+
* <div role="menu"> ← nested sub-menu
|
|
43
|
+
* <button role="menuitem" /> ← isAtCurrentMenuLevel → false
|
|
44
|
+
* </div>
|
|
45
|
+
* </div>
|
|
46
|
+
* ```
|
|
47
|
+
* Uses the simple check: `element.closest('[role="menu"]') === container`
|
|
48
|
+
*
|
|
49
|
+
* **2. Container is a wrapper without `role="menu"`** (used by dropdown-menu,
|
|
50
|
+
* where `MenuGroup` owns `role="menu"` but does not accept a ref):
|
|
51
|
+
* ```
|
|
52
|
+
* <div ref={containerRef}> ← wrapper (no role="menu")
|
|
53
|
+
* <MenuGroup role="menu">
|
|
54
|
+
* <button role="menuitem" /> ← isAtCurrentMenuLevel → true
|
|
55
|
+
* <div role="menu"> ← nested sub-menu
|
|
56
|
+
* <button role="menuitem" /> ← isAtCurrentMenuLevel → false
|
|
57
|
+
* </div>
|
|
58
|
+
* </MenuGroup>
|
|
59
|
+
* </div>
|
|
60
|
+
* ```
|
|
61
|
+
* Falls back to walking the DOM to check that the element's closest
|
|
62
|
+
* `role="menu"` is the container's own menu (not doubly nested).
|
|
63
|
+
*
|
|
64
|
+
* Ideally all consumers should use pattern 1 (place the ref directly on the
|
|
65
|
+
* `role="menu"` element). Pattern 2 exists because `@atlaskit/menu`'s
|
|
66
|
+
* `MenuGroup` does not currently accept a ref. If `MenuGroup` gains ref
|
|
67
|
+
* support in the future, dropdown-menu should switch to pattern 1 and the
|
|
68
|
+
* fallback path can be removed.
|
|
69
|
+
*
|
|
70
|
+
* Used both as a `TFocusableFilter` (to scope getNextFocusable etc.) and as
|
|
71
|
+
* a guard to prevent parent menu handlers from acting on events that
|
|
72
|
+
* belong to a nested menu.
|
|
73
|
+
*/
|
|
74
|
+
function isAtCurrentMenuLevel(element, container) {
|
|
75
|
+
var closestMenu = element.closest(menuScope);
|
|
76
|
+
|
|
77
|
+
// Container itself has role="menu". Element belongs to this level
|
|
78
|
+
// if its closest menu is the container.
|
|
79
|
+
if (container.getAttribute('role') === 'menu') {
|
|
80
|
+
return closestMenu === container;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Container is a wrapper without role="menu" (e.g. dropdown-menu
|
|
84
|
+
// wraps a MenuGroup). The element belongs to the top level if its
|
|
85
|
+
// closest role="menu" ancestor is a direct child of the container,
|
|
86
|
+
// i.e. there is no nested role="menu" between them.
|
|
87
|
+
if (closestMenu === null) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Walk up from the closest menu to see if it is "owned" by this
|
|
92
|
+
// container without passing through another role="menu" first.
|
|
93
|
+
return reachesContainerWithoutNestedMenu(closestMenu.parentElement, container);
|
|
94
|
+
}
|