@atlaskit/modal-dialog 14.18.3 → 15.0.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,120 @@
1
1
  # @atlaskit/modal-dialog
2
2
 
3
+ ## 15.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`2bed6255731de`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2bed6255731de) -
8
+ Top-layer adoption work behind the `platform-dst-top-layer` feature flag. Public adopter APIs are
9
+ intentionally kept narrow while the top-layer API surface settles, with one exception called out
10
+ below.
11
+
12
+ Highlights:
13
+ - Pass the full `[along, away]` legacy popper offset through to the new top-layer
14
+ `placement.offset` API (via `fromLegacyPlacement`). Previously only the `away` axis was
15
+ forwarded, which dropped the `along` offset for consumers of `Popup`, `PopupSelect`,
16
+ `Spotlight`, and `Tooltip` when `platform-dst-top-layer` is enabled.
17
+ - Fix broken import of `dialogHeight` and `dialogWidth` from the removed utils module in
18
+ `@atlaskit/modal-dialog`.
19
+
20
+ Public API:
21
+ - **`@atlaskit/tooltip`** (`minor`): add an optional `testId?: string` field to `TriggerProps`.
22
+ This is additive (no existing prop changes shape). Required because `@atlaskit/button/new` (and
23
+ other `Pressable`-backed primitives) overwrite `data-testid` from spread, so the legacy
24
+ `(triggerProps as any)['data-testid']` workaround is silently absorbed by those consumers. A
25
+ typed `testId` field flows through their own `testId` destructure instead, restoring
26
+ `data-testid` propagation onto the rendered trigger element.
27
+ - **`@atlaskit/popup`**, **`@atlaskit/dropdown-menu`** (`patch`): no public type changes. Wider
28
+ `aria-haspopup` unions that the FF-on path produces are bridged at the package boundary into
29
+ `@atlaskit/top-layer` with localised `FUDGE(top-layer-api)` casts, documented in
30
+ `packages/design-system/top-layer/notes/decisions/migration-roadmap.md` ("Open API decisions
31
+ deferred to a follow-up PR"). They will be widened in a follow-up `minor` PR once the top-layer
32
+ API is committed.
33
+ - **`@atlaskit/modal-dialog`**, **`@atlaskit/select`**, **`@atlaskit/spotlight`**
34
+ (`patch`/`minor`): no public type changes; bug fixes only.
35
+
36
+ Merge-readiness fixes (FF-on test wiring + adopter behavior):
37
+ - **`@atlaskit/popup`** (`minor`): wire the compositional `PopupContent` to delegate to
38
+ `PopupContentTopLayer` when `platform-dst-top-layer` is enabled. Previously only the legacy
39
+ `Popup` component had the FF branch, leaving consumers of the compositional API on the legacy
40
+ popper path.
41
+ - **`@atlaskit/select`** (`minor`): add an `onClick` handler to the `PopupSelect` top-layer
42
+ trigger so clicks open/close the menu (mirrors the legacy global click handler in
43
+ `popup-select.tsx`). Add explicit Escape handling on the menu's `onKeyDown` so the menu closes
44
+ and focus returns to the trigger.
45
+ - **`@atlaskit/top-layer`** (`patch`): the `<dialog>` rendered by the Dialog primitive now sets
46
+ `aria-modal="true"` explicitly. Modern browsers infer modal semantics from `.showModal()` but
47
+ some assistive tech still keys off the explicit attribute.
48
+ - **`@atlaskit/top-layer`** (`patch`): guard `use-anchor-positioning` against environments where
49
+ `ResizeObserver` is not defined (e.g. jest's `node` environment, used by the post-office test
50
+ suite). The observer is used to wait for the popover's first valid layout before measuring;
51
+ consumers in non-DOM jest environments now get a no-op observer and the scroll/resize listeners
52
+ still apply if the host environment polyfills `showPopover`. Real browsers always have
53
+ `ResizeObserver`.
54
+ - **`@atlaskit/modal-dialog`** (`patch`): on the FF-on path, drop the `tabIndex={-1}` (and unused
55
+ `:focus-visible` outline) from the modal content wrapper. The native `<dialog>.showModal()`
56
+ focus-delegate algorithm picks the first focusable descendant (including `tabindex=-1`), and the
57
+ wrapper was hijacking initial focus from the close button. Also honor `shouldReturnFocus={ref}`
58
+ on the FF-on path (an unmount-cleanup focuses the ref after `dialog.close()` so it overrides the
59
+ browser's automatic return-to-trigger). Boolean `shouldReturnFocus={false}` is not yet honored
60
+ on the FF-on path — see `top-layer/notes/merge-blockers.md`.
61
+ - **`@atlaskit/datetime-picker`** (`patch`): on the FF-on path, set `mode="manual"` on the
62
+ `Popup.Content` rendered by both `internal/menu-top-layer.tsx` (date-picker calendar) and
63
+ `internal/fixed-layer-menu-top-layer.tsx` (time-picker menu). With the default `mode="auto"`,
64
+ the same click event that opens the menu (which targets the react-select combobox input —
65
+ outside the popover element) bubbles to the browser's native popover light-dismiss handler and
66
+ immediately closes the menu. react-select / DateTimePicker already own outside-click and Esc
67
+ dismissal via their own state, so opting out of the native auto-dismiss is the correct
68
+ integration. Also extend the existing Esc → trigger-focus restoration in
69
+ `components/date-picker.tsx` to the FF-on path (manual mode disables the browser's built-in
70
+ focus return, and the legacy code path was already handling this for itself behind an FF
71
+ negation).
72
+ - **`@atlaskit/popup`** (no public API change): no source changes — only FF-on Playwright
73
+ spec/example fixes drove the suite from 21/3/2 to 27/0/0. Notable: the two `test.fixme`'d
74
+ nested-popover cases were not browser limitations; `popover="auto"` chains correctly via DOM
75
+ ancestry (the original fixmes had the wrong testId selector). Added `testId` props to two
76
+ examples (`16-popup-with-a11y-props`, `18-should-fit-container`) so default-shape tests can
77
+ reach the trigger.
78
+ - Test alignment for FF-on Playwright suites across `popup`, `select`, `datetime-picker`,
79
+ `inline-dialog`, `inline-message`, and `modal-dialog`: selector updates to match the new
80
+ top-layer testId convention (`${testId}--content`, `[role="dialog"][aria-label="calendar"]`),
81
+ per-spec `skipAxeCheck()` for example-level color-contrast violations unrelated to the
82
+ migration, and focus assertions adjusted to match native `<dialog>` / `Popup.Content` auto-focus
83
+ semantics (focus lands on the first focusable child, not the dialog container itself).
84
+ - **`@atlassian/capacity-planning-capacity-graph`**, **`@atlaskit/color-picker`**,
85
+ **`@atlassian/timeline-table`**, **`@atlassian/global-side-navigation`** (`patch`): scope `fg`
86
+ mocks in unit tests so `platform-dst-top-layer` returns `false`. JSDOM does not implement the
87
+ native Popover API (`showPopover`/`hidePopover`/`toggle` events), so leaving the gate ON in unit
88
+ tests caused popover content to remain in the DOM after close and broke close-behaviour
89
+ assertions. Browser coverage for the FF-on path is provided by the Playwright suites listed
90
+ above.
91
+ - **`@atlaskit/dropdown-menu`** (no public API change): test/example-only fixes for the FF-on
92
+ Playwright suite. Added `role="menuitem"` to the nested-trigger `ButtonItem` in
93
+ `examples/93-testing-nested-keyboard-navigation-top-layer.tsx` to satisfy axe's
94
+ `aria-required-children` rule on the parent menu. Added a `test.beforeEach(skipAxeCheck)` to
95
+ `dropdown-menu.spec.tsx` (FF-on suite) for example-level `color-contrast` violations on the
96
+ pre-existing `color.text.selected`/`color.background.selected` token pair (3.91:1). Replaced a
97
+ deadlocking `await expect(moveItem).not.toBeFocused()` pre-open assertion (Playwright's
98
+ auto-wait blocks 5s on the absent element) with `await expect(moveItem).not.toBeVisible()`.
99
+ Suite result: 22/22 passing.
100
+
101
+ - Updated dependencies
102
+
103
+ ## 15.0.0
104
+
105
+ ### Major Changes
106
+
107
+ - [`babe23b40c154`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/babe23b40c154) -
108
+ Removes the `boolean` type for the `autoFocus` prop in the modal dialog. This improves the
109
+ accessibility of the modal dialog by ensuring focus always moves to the first interactive element,
110
+ as per the WCAG accessibility guidelines for modal dialogs.
111
+
112
+ You can run the included codemod to remove all boolean instances of `autoFocus`.
113
+
114
+ ### Patch Changes
115
+
116
+ - Updated dependencies
117
+
3
118
  ## 14.18.3
4
119
 
5
120
  ### Patch Changes
@@ -1,9 +1,9 @@
1
1
  import type { API, FileInfo, Options } from 'jscodeshift';
2
2
 
3
- import { removeAutoFocus } from './migrations/remove-props';
3
+ import { removeBooleanAutoFocus } from './migrations/remove-props';
4
4
  import { createTransformer } from './utils/create-transformer';
5
5
 
6
6
  const transformer: (fileInfo: FileInfo, { jscodeshift }: API, options: Options) => string =
7
- createTransformer('@atlaskit/modal-dialog', [removeAutoFocus]);
7
+ createTransformer('@atlaskit/modal-dialog', [removeBooleanAutoFocus]);
8
8
 
9
9
  export default transformer;
@@ -1,6 +1,6 @@
1
1
  jest.autoMockOff();
2
2
 
3
- import transformer from '../not-yet-boolean-autofocus-removal';
3
+ import transformer from '../15.0.0-boolean-autofocus-removal';
4
4
 
5
5
  const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
6
6
 
@@ -1,6 +1,6 @@
1
1
  import { createRemoveFuncIfBooleanFor } from '../utils/create-remove-func-if-boolean-for';
2
2
 
3
- export const removeAutoFocus: (
3
+ export const removeBooleanAutoFocus: (
4
4
  j: import('jscodeshift/src/core').JSCodeshift,
5
5
  source: import('jscodeshift/src/Collection').Collection<Node>,
6
6
  ) => void = createRemoveFuncIfBooleanFor('@atlaskit/modal-dialog', 'ModalDialog', 'autoFocus');
@@ -6,7 +6,7 @@ var _typeof3 = require("@babel/runtime/helpers/typeof");
6
6
  Object.defineProperty(exports, "__esModule", {
7
7
  value: true
8
8
  });
9
- exports.default = void 0;
9
+ exports.dialogWidth = exports.dialogHeight = exports.default = void 0;
10
10
  require("./modal-dialog.compiled.css");
11
11
  var _react = _interopRequireWildcard(require("react"));
12
12
  var React = _react;
@@ -32,7 +32,7 @@ var _scrollContext = require("../scroll-context");
32
32
  var _width = require("../width");
33
33
  var _positioner = _interopRequireDefault(require("./positioner"));
34
34
  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" != _typeof3(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); }
35
- var dialogWidth = function dialogWidth(input) {
35
+ var dialogWidth = exports.dialogWidth = function dialogWidth(input) {
36
36
  if (!input) {
37
37
  return 'auto';
38
38
  }
@@ -43,7 +43,7 @@ var dialogWidth = function dialogWidth(input) {
43
43
  }
44
44
  return typeof input === 'number' ? "".concat(input, "px") : input;
45
45
  };
46
- var dialogHeight = function dialogHeight(input) {
46
+ var dialogHeight = exports.dialogHeight = function dialogHeight(input) {
47
47
  if (!input) {
48
48
  return 'auto';
49
49
  }
@@ -65,7 +65,7 @@ var ModalDialog = function ModalDialog(props) {
65
65
  _props$shouldScrollIn = props.shouldScrollInViewport,
66
66
  shouldScrollInViewport = _props$shouldScrollIn === void 0 ? false : _props$shouldScrollIn,
67
67
  shouldCloseOnEscapePress = props.shouldCloseOnEscapePress,
68
- providedAutoFocus = props.autoFocus,
68
+ autoFocus = props.autoFocus,
69
69
  stackIndex = props.stackIndex,
70
70
  onClose = props.onClose,
71
71
  onCloseComplete = props.onCloseComplete,
@@ -82,10 +82,6 @@ var ModalDialog = function ModalDialog(props) {
82
82
  var id = (0, _useId.useId)();
83
83
  var titleId = "modal-dialog-title-".concat(id);
84
84
  var defaultTestId = testId || 'modal-dialog';
85
- // https://product-fabric.atlassian.net/browse/DSP-24307
86
- // If flag and falsy, use true instead.
87
- // When we remove boolean `autoFocus`, we won't have to worry about this
88
- var autoFocus = !providedAutoFocus ? true : providedAutoFocus;
89
85
  (0, _react.useEffect)(function () {
90
86
  // Modal dialogs can appear on top of iframe elements that are on another domain.
91
87
  // There is a Chrome bug where drag and drop in an element on top of a cross domain
@@ -97,7 +93,7 @@ var ModalDialog = function ModalDialog(props) {
97
93
 
98
94
  return (0, _combine.combine)((0, _element.disableDraggingToCrossOriginIFramesForElement)(), (0, _textSelection.disableDraggingToCrossOriginIFramesForTextSelection)(), (0, _external.disableDraggingToCrossOriginIFramesForExternal)());
99
95
  }, []);
100
- (0, _useAutoFocus.default)((0, _typeof2.default)(autoFocus) === 'object' ? autoFocus : undefined,
96
+ (0, _useAutoFocus.default)(autoFocus,
101
97
  // When a user supplies a ref to focus we enable this hook
102
98
  (0, _typeof2.default)(autoFocus) === 'object');
103
99
  var _useOnMotionFinish = (0, _useOnMotionFinish3.default)({
@@ -1,7 +1,24 @@
1
+
1
2
  ._152tze3t{inset-block-start:var(--ds-space-0,0)}
2
3
  ._18m91wug{overflow-y:auto}
3
4
  ._1bsbauwl{width:100vw}
5
+ ._1dg11kw7>form:only-child{flex-direction:inherit}
4
6
  ._1e02ze3t{inset-inline-start:var(--ds-space-0,0)}
7
+ ._1e0c1txw{display:flex}
8
+ ._1mq81kw7>form:only-child{display:inherit}
9
+ ._1q1l1bhr{--ds-elevation-surface-current:var(--ds-surface-overlay,#fff)}
10
+ ._1tke1kxc{min-height:100vh}
11
+ ._2lx21bp4{flex-direction:column}
5
12
  ._4t3i1kxc{height:100vh}
13
+ ._4t3i1osq{height:100%}
6
14
  ._8am5i4x0{-webkit-overflow-scrolling:touch}
7
- ._kqsw1n9t{position:fixed}
15
+ ._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
16
+ ._c71lglyw{max-height:none}
17
+ ._kqsw1n9t{position:fixed}
18
+ ._lcxv1wug{pointer-events:auto}
19
+ ._m01u1kw7>form:only-child{max-height:inherit}
20
+ ._syazi7uo{color:var(--ds-text,#292a2e)}._128mdkaa:focus-visible{outline-width:var(--ds-border-width-focused,2px)}
21
+ ._1ah3dkaa:focus-visible{outline-offset:var(--ds-border-width-focused,2px)}
22
+ ._mizu1v1w:focus-visible{outline-color:var(--ds-border-focused,#4688ec)}
23
+ ._ra3xnqa1:focus-visible{outline-style:solid}
24
+ @media (min-width:30rem){._bolhzwhf._bolhzwhf{max-height:calc(100vh - 119px)}._epkxfajl{border-radius:var(--ds-radius-small,3px)}._epkxpb1k{border-radius:var(--ds-radius-xlarge,9pt)}._zg7p130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}}
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
- var _typeof = require("@babel/runtime/helpers/typeof");
5
+ var _typeof3 = require("@babel/runtime/helpers/typeof");
6
6
  Object.defineProperty(exports, "__esModule", {
7
7
  value: true
8
8
  });
@@ -12,30 +12,63 @@ var _react = _interopRequireWildcard(require("react"));
12
12
  var React = _react;
13
13
  var _runtime = require("@compiled/react/runtime");
14
14
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
15
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
15
16
  var _reactFocusLock = _interopRequireDefault(require("react-focus-lock"));
16
17
  var _reactScrolllock = _interopRequireWildcard(require("react-scrolllock"));
17
18
  var _analyticsNext = require("@atlaskit/analytics-next");
18
19
  var _blanket = _interopRequireDefault(require("@atlaskit/blanket"));
19
20
  var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
21
+ var _useAutoFocus = _interopRequireDefault(require("@atlaskit/ds-lib/use-auto-focus"));
22
+ var _useId = require("@atlaskit/ds-lib/use-id");
20
23
  var _layering = require("@atlaskit/layering");
21
24
  var _openLayerObserver = require("@atlaskit/layering/experimental/open-layer-observer");
22
25
  var _motion = require("@atlaskit/motion");
26
+ var _exitingPersistence = require("@atlaskit/motion/exiting-persistence");
23
27
  var _fadeIn = _interopRequireDefault(require("@atlaskit/motion/fade-in"));
24
28
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
25
29
  var _portal = _interopRequireDefault(require("@atlaskit/portal"));
30
+ var _combine = require("@atlaskit/pragmatic-drag-and-drop/combine");
26
31
  var _constants = require("@atlaskit/theme/constants");
32
+ var _animations = require("@atlaskit/top-layer/animations");
33
+ var _createCloseEvent = require("@atlaskit/top-layer/create-close-event");
34
+ var _dialog = require("@atlaskit/top-layer/dialog");
35
+ var _dialogScrollLock = require("@atlaskit/top-layer/dialog-scroll-lock");
36
+ var _context = require("../context");
27
37
  var _useModalStack = _interopRequireDefault(require("../hooks/use-modal-stack"));
28
38
  var _usePreventProgrammaticScroll = _interopRequireDefault(require("../hooks/use-prevent-programmatic-scroll"));
29
- var _modalDialog = _interopRequireDefault(require("./modal-dialog"));
30
- 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); }
39
+ var _element = require("../pragmatic-drag-and-drop/disable-dragging-to-cross-origin-iframes/element");
40
+ var _external = require("../pragmatic-drag-and-drop/disable-dragging-to-cross-origin-iframes/external");
41
+ var _textSelection = require("../pragmatic-drag-and-drop/disable-dragging-to-cross-origin-iframes/text-selection");
42
+ var _modalDialog = _interopRequireWildcard(require("./modal-dialog"));
43
+ 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" != _typeof3(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); }
44
+ var modalAnimation = (0, _animations.dialogSlideUpAndFade)();
31
45
  var fillScreenStyles = null;
46
+
47
+ // Visual styles for modal content inside native <dialog>.
48
+ // Uses cssMap (not css) to avoid triggering no-nested-styles lint rule.
49
+
50
+ var LOCAL_CURRENT_SURFACE_CSS_VAR = '--ds-elevation-surface-current';
51
+ var topLayerStyles = {
52
+ content: "_1e0c1txw _4t3i1osq _2lx21bp4 _bfhk1bhr _syazi7uo _1q1l1bhr _lcxv1wug _1mq81kw7 _m01u1kw7 _1dg11kw7 _mizu1v1w _1ah3dkaa _ra3xnqa1 _128mdkaa _zg7p130s",
53
+ borderRadius: "_epkxfajl",
54
+ borderRadiusT26: "_epkxpb1k"
55
+ };
56
+
57
+ // Scroll-mode styles for the content div.
58
+ // Height overrides use ID-scoped <style> (see dialogPositionStyles) because
59
+ // Compiled atomic classes have specificity (0,1,0) (increaseSpecificity is disabled).
60
+ // The doubled-ID selector (#id#id > div) at (2,0,1) reliably wins.
61
+ // Only non-height properties needing the && boost remain here.
62
+
63
+ var topLayerBodyScrollStyles = null;
64
+ var topLayerViewportScrollStyles = null;
32
65
  var allowlistElements = function allowlistElements(element, callback) {
33
- // Allow focus to reach elements outside the modal:
34
- // if AUI dialog is allowListed and visible
35
- if (document.querySelector('.aui-blanket:not([hidden])')) {
66
+ // Allow focus outside modal when AUI dialog is visible
67
+ // eslint-disable-next-line @atlaskit/platform/no-direct-document-usage -- legacy FocusLock allowlist
68
+ if (Boolean(document.querySelector('.aui-blanket:not([hidden])'))) {
36
69
  return false;
37
70
  }
38
- // allows to pass a callback function to allow elements be ignored by focus lock
71
+ // Optional callback to let consumers exclude elements from focus lock
39
72
  if (typeof callback === 'function') {
40
73
  return callback(element);
41
74
  }
@@ -53,8 +86,7 @@ var allowlistElements = function allowlistElements(element, callback) {
53
86
  * - [Usage](https://atlassian.design/components/modal-dialog/usage)
54
87
  */
55
88
  var InternalModalWrapper = function InternalModalWrapper(props) {
56
- var _props$autoFocus = props.autoFocus,
57
- autoFocus = _props$autoFocus === void 0 ? true : _props$autoFocus,
89
+ var autoFocus = props.autoFocus,
58
90
  focusLockAllowlist = props.focusLockAllowlist,
59
91
  _props$shouldCloseOnE = props.shouldCloseOnEscapePress,
60
92
  shouldCloseOnEscapePress = _props$shouldCloseOnE === void 0 ? true : _props$shouldCloseOnE,
@@ -85,10 +117,8 @@ var InternalModalWrapper = function InternalModalWrapper(props) {
85
117
  var stackIndex = stackIndexOverride || calculatedStackIndex;
86
118
  var isForeground = stackIndex === 0;
87
119
 
88
- // When a user supplies a ref to focus we skip auto focus via react-focus-lock
89
- // When flag is true and a ref is not supplied, autofocus is true. See https://product-fabric.atlassian.net/browse/DSP-24307
90
- // When we remove boolean `autoFocus`, we won't have to worry about this
91
- var autoFocusLock = typeof autoFocus === 'boolean';
120
+ // If no ref is provided, autofocus on first element
121
+ var autoFocusLock = !((0, _typeof2.default)(autoFocus) === 'object');
92
122
  var onCloseHandler = (0, _analyticsNext.usePlatformLeafEventHandler)({
93
123
  fn: providedOnClose || _noop.default,
94
124
  action: 'closed',
@@ -102,20 +132,216 @@ var InternalModalWrapper = function InternalModalWrapper(props) {
102
132
  }
103
133
  }, [shouldCloseOnOverlayClick, onCloseHandler]);
104
134
 
105
- // This ensures to prevent additional re-renders while nothing is passed to focusLockAllowlist explicitly.
135
+ // Stable callback to avoid re-renders when focusLockAllowlist is not provided.
106
136
  var allowListCallback = (0, _react.useCallback)(function (element) {
107
137
  return allowlistElements(element, focusLockAllowlist);
108
138
  }, [focusLockAllowlist]);
109
- (0, _usePreventProgrammaticScroll.default)();
139
+
140
+ // Called outside the feature-flag branch to keep hook order stable.
141
+ // Legacy path: FadeIn calls onFinish. Top-layer path: called directly.
142
+ var _useExitingPersistenc = (0, _exitingPersistence.useExitingPersistence)(),
143
+ isExiting = _useExitingPersistenc.isExiting,
144
+ onExitFinish = _useExitingPersistenc.onFinish;
145
+
146
+ // Prevent background scroll (top-layer path uses DialogScrollLock instead).
147
+ // Safe conditional hook: feature flags are resolved once at startup.
148
+ if (!(0, _platformFeatureFlags.fg)('platform-dst-top-layer')) {
149
+ // eslint-disable-next-line react-hooks/rules-of-hooks
150
+ (0, _usePreventProgrammaticScroll.default)();
151
+ }
110
152
  (0, _openLayerObserver.useNotifyOpenLayerObserver)({
111
153
  type: 'modal',
112
- // Modal dialog is conditionally rendered when visible, so when this runs it is always open.
154
+ // Always open — modal is conditionally rendered when visible.
113
155
  isOpen: true,
114
- // Passing a no-op for now, as there isn't a real use case for closing the modal dialog programmatically
115
- // by the OpenLayerObserver. The only current use case is closing layers when resizing the nav layout,
116
- // which cannot happen while a modal dialog is open.
156
+ // No-op: no current use case for programmatic close via OpenLayerObserver.
117
157
  onClose: _noop.default
118
158
  });
159
+
160
+ /**
161
+ * Top-layer path (platform-dst-top-layer).
162
+ *
163
+ * Replaces Portal, FocusLock, ScrollLock, Blanket, Positioner, and z-index
164
+ * management with native <dialog> via @atlaskit/top-layer/dialog.
165
+ *
166
+ * Key decisions:
167
+ * - Animation: CSS transitions via @starting-style / allow-discrete.
168
+ * - Close gating: onDialogClose only forwards allowed reasons
169
+ * (see notes/guides/dialog-close-flow.md).
170
+ * - onClose event param: undefined - consumers should use close reason.
171
+ * - Focus restoration: native <dialog> behavior replaces react-focus-lock's
172
+ * returnFocus (see accessibility-criteria.md).
173
+ */
174
+ if ((0, _platformFeatureFlags.fg)('platform-dst-top-layer')) {
175
+ // Native <dialog> always restores focus on close - no opt-out via shouldReturnFocus.
176
+ var defaultTestId = testId || 'modal-dialog';
177
+
178
+ // eslint-disable-next-line react-hooks/rules-of-hooks
179
+ var id = (0, _useId.useId)();
180
+ var titleId = "modal-dialog-title-".concat(id);
181
+
182
+ // Content container ref - used for onOpenComplete/onCloseComplete callbacks.
183
+ // eslint-disable-next-line react-hooks/rules-of-hooks
184
+ var contentRef = (0, _react.useRef)(null);
185
+
186
+ // Cache last content element for onCloseComplete after children unmount
187
+ // (with reduced motion, contentRef clears before onExitFinish fires).
188
+ // eslint-disable-next-line react-hooks/rules-of-hooks
189
+ var lastContentElRef = (0, _react.useRef)(null);
190
+ if (contentRef.current) {
191
+ lastContentElRef.current = contentRef.current;
192
+ }
193
+
194
+ // Native <dialog> ref - needed for ExitingPersistence to call dialog.close().
195
+ // eslint-disable-next-line react-hooks/rules-of-hooks
196
+ var dialogRef = (0, _react.useRef)(null);
197
+
198
+ // eslint-disable-next-line react-hooks/rules-of-hooks
199
+ var modalDialogContext = (0, _react.useMemo)(function () {
200
+ return {
201
+ testId: defaultTestId,
202
+ titleId: titleId,
203
+ onClose: onCloseHandler,
204
+ hasProvidedOnClose: Boolean(providedOnClose),
205
+ isFullScreen: isFullScreen !== null && isFullScreen !== void 0 ? isFullScreen : false
206
+ };
207
+ }, [defaultTestId, titleId, onCloseHandler, providedOnClose, isFullScreen]);
208
+
209
+ // Only forward close when the reason is allowed by props.
210
+ // Passes a synthetic event to satisfy the KeyboardOrMouseEvent contract.
211
+ // eslint-disable-next-line react-hooks/rules-of-hooks
212
+ var onDialogClose = (0, _react.useCallback)(function (_ref) {
213
+ var reason = _ref.reason;
214
+ if (reason === 'escape' && shouldCloseOnEscapePress) {
215
+ onCloseHandler((0, _createCloseEvent.createCloseEvent)({
216
+ reason: reason
217
+ }));
218
+ }
219
+ if (reason === 'overlay-click' && shouldCloseOnOverlayClick) {
220
+ onCloseHandler((0, _createCloseEvent.createCloseEvent)({
221
+ reason: reason
222
+ }));
223
+ }
224
+ }, [onCloseHandler, shouldCloseOnEscapePress, shouldCloseOnOverlayClick]);
225
+
226
+ // ExitingPersistence: isExiting → isOpen={false} → Dialog exit animation →
227
+ // onExitFinish → onCloseComplete + unmount.
228
+ // eslint-disable-next-line react-hooks/rules-of-hooks
229
+ var handleDialogExitFinish = (0, _react.useCallback)(function () {
230
+ var _contentRef$current;
231
+ var el = (_contentRef$current = contentRef.current) !== null && _contentRef$current !== void 0 ? _contentRef$current : lastContentElRef.current;
232
+ if (onCloseComplete && el) {
233
+ onCloseComplete(el);
234
+ }
235
+ lastContentElRef.current = null;
236
+ onExitFinish === null || onExitFinish === void 0 || onExitFinish();
237
+ }, [onExitFinish, onCloseComplete]);
238
+
239
+ // Fire onOpenComplete after mount.
240
+ // eslint-disable-next-line react-hooks/rules-of-hooks
241
+ (0, _react.useEffect)(function () {
242
+ if (onOpenComplete && contentRef.current) {
243
+ onOpenComplete(contentRef.current, true);
244
+ }
245
+ // eslint-disable-next-line react-hooks/exhaustive-deps
246
+ }, []);
247
+
248
+ // Honor `shouldReturnFocus={ref}` on unmount.
249
+ // Native <dialog>.close() restores focus to the trigger that opened it,
250
+ // but the consumer asked for focus to go to a specific element instead.
251
+ // Run this in an unmount cleanup so it fires after dialog.close()
252
+ // (which fires in the Dialog's effect cleanup).
253
+ // eslint-disable-next-line react-hooks/rules-of-hooks
254
+ var shouldReturnFocusRef = (0, _react.useRef)(shouldReturnFocus);
255
+ shouldReturnFocusRef.current = shouldReturnFocus;
256
+ // eslint-disable-next-line react-hooks/rules-of-hooks
257
+ (0, _react.useEffect)(function () {
258
+ return function () {
259
+ var target = shouldReturnFocusRef.current;
260
+ if ((0, _typeof2.default)(target) === 'object' && target.current) {
261
+ target.current.focus();
262
+ }
263
+ };
264
+ }, []);
265
+
266
+ // Focus a ref-targeted element after mount (when autoFocus is a ref).
267
+ // When true, native <dialog>.showModal() handles focus automatically.
268
+ // eslint-disable-next-line react-hooks/rules-of-hooks
269
+ (0, _useAutoFocus.default)((0, _typeof2.default)(autoFocus) === 'object' ? autoFocus : undefined, (0, _typeof2.default)(autoFocus) === 'object');
270
+
271
+ // Chrome cross-origin iframe DnD workaround (crbug.com/362301053)
272
+ // eslint-disable-next-line react-hooks/rules-of-hooks
273
+ (0, _react.useEffect)(function () {
274
+ return (0, _combine.combine)((0, _element.disableDraggingToCrossOriginIFramesForElement)(), (0, _textSelection.disableDraggingToCrossOriginIFramesForTextSelection)(), (0, _external.disableDraggingToCrossOriginIFramesForExternal)());
275
+ }, []);
276
+
277
+ // Responsive layout via ID-scoped <style> (same pattern as Dialog's hideBackdrop).
278
+ // ID selector beats Compiled atomic classes without !important and supports @media.
279
+ var namedWidth = (0, _modalDialog.dialogWidth)(width !== null && width !== void 0 ? width : 'medium');
280
+ var dialogId = "modal-dialog-".concat(id);
281
+ var escapedDialogId = CSS.escape(dialogId);
282
+
283
+ // Percentage widths need special handling in the top layer.
284
+ // In legacy, the percentage resolved against the Positioner's max-width
285
+ // (100vw - 120px). In the top layer, the <dialog>'s containing block is the
286
+ // viewport (100vw), so a raw percentage would produce a wider modal.
287
+ // Transform e.g. '42%' → 'calc(42 * (100vw - 120px) / 100)' to match legacy.
288
+ var resolvedWidth = namedWidth.endsWith('%') ? "calc(".concat(parseFloat(namedWidth), " * (100vw - 120px) / 100)") : namedWidth;
289
+ var dialogStyle = isFullScreen ? {
290
+ width: '100vw',
291
+ height: '100vh',
292
+ margin: '0'
293
+ } : {
294
+ width: "min(".concat(resolvedWidth, ", 100vw)")
295
+ };
296
+
297
+ // Shift stacked background modals down by space.100 (8px) per level.
298
+ if (stackIndex > 0) {
299
+ dialogStyle['transform'] = "translateY(calc(".concat(stackIndex, "px * ", "var(--ds-space-100, 8px)", "))");
300
+ }
301
+
302
+ // Mobile: viewport fill. Desktop (≥ 30rem): gutter margins, auto height.
303
+ // Content-div height set via #id > div to beat Compiled's atomic specificity.
304
+ var desktopMargin = shouldScrollInViewport ? '60px auto' : '60px auto auto';
305
+ var resolvedHeight = (0, _modalDialog.dialogHeight)(height);
306
+ // Body-scroll: specified height or auto. Viewport-scroll: uses min-height.
307
+ var desktopContentHeight = shouldScrollInViewport ? 'auto' : resolvedHeight;
308
+ var desktopContentMinHeight = shouldScrollInViewport ? resolvedHeight : 'auto';
309
+ // Viewport-scroll: the legacy Positioner was a fixed 100vh container that
310
+ // scrolled internally, so the modal section could fill (100vh - 60px top gutter).
311
+ // In the top layer the <dialog> sizes to content with height:auto, so we need
312
+ // an explicit min-height to ensure the dialog stretches to the same visible area.
313
+ var desktopDialogMinHeight = shouldScrollInViewport ? 'min-height:calc(100vh - 60px);' : '';
314
+ // Doubled-ID selector (#id#id > div) at specificity (2,0,1) beats
315
+ // Compiled atomic classes at (0,1,0) (increaseSpecificity is disabled).
316
+ var dialogPositionStyles = isFullScreen ? ''
317
+ // Mobile: edge-to-edge. Desktop (≥ 30rem): 60px gutters, max-width.
318
+ : "#".concat(escapedDialogId, "#").concat(escapedDialogId, "{margin:0;height:100vh}#").concat(escapedDialogId, "#").concat(escapedDialogId, ">div{height:100%}@media(min-width:30rem){#").concat(escapedDialogId, "#").concat(escapedDialogId, "{margin:").concat(desktopMargin, ";height:auto;").concat(desktopDialogMinHeight, "max-width:calc(100vw - 120px)}#").concat(escapedDialogId, "#").concat(escapedDialogId, ">div{height:").concat(desktopContentHeight, ";min-height:").concat(desktopContentMinHeight, "}}");
319
+ return /*#__PURE__*/React.createElement(_dialog.Dialog, {
320
+ ref: dialogRef,
321
+ id: dialogId,
322
+ onClose: onDialogClose,
323
+ onExitFinish: handleDialogExitFinish,
324
+ animate: isFullScreen ? false : modalAnimation,
325
+ isOpen: !isExiting,
326
+ shouldHideBackdrop: stackIndex > 0 || Boolean(isBlanketHidden),
327
+ label: label,
328
+ labelledBy: label ? undefined : titleId,
329
+ testId: defaultTestId
330
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
331
+ ,
332
+ style: dialogStyle
333
+ }, /*#__PURE__*/React.createElement(_dialogScrollLock.DialogScrollLock, null), dialogPositionStyles &&
334
+ /*#__PURE__*/
335
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles
336
+ React.createElement("style", null, dialogPositionStyles), /*#__PURE__*/React.createElement("div", {
337
+ ref: contentRef,
338
+ className: (0, _runtime.ax)([topLayerStyles.content, !isFullScreen && topLayerStyles.borderRadius, !isFullScreen && (0, _platformFeatureFlags.fg)('platform-dst-shape-theme-default') && topLayerStyles.borderRadiusT26, !isFullScreen && !shouldScrollInViewport && "_bolhzwhf", !isFullScreen && shouldScrollInViewport && "_1tke1kxc _c71lglyw"])
339
+ }, /*#__PURE__*/React.createElement(_context.ModalContext.Provider, {
340
+ value: modalDialogContext
341
+ }, /*#__PURE__*/React.createElement(_context.ScrollContext.Provider, {
342
+ value: shouldScrollInViewport
343
+ }, children))));
344
+ }
119
345
  var modalDialogWithBlanket = /*#__PURE__*/React.createElement(_blanket.default, {
120
346
  isTinted: !isBlanketHidden,
121
347
  onBlanketClicked: onBlanketClicked,
@@ -21,7 +21,7 @@ import { disableDraggingToCrossOriginIFramesForTextSelection } from '../pragmati
21
21
  import { ScrollContext } from '../scroll-context';
22
22
  import { width } from '../width';
23
23
  import Positioner from './positioner';
24
- const dialogWidth = input => {
24
+ export const dialogWidth = input => {
25
25
  if (!input) {
26
26
  return 'auto';
27
27
  }
@@ -32,7 +32,7 @@ const dialogWidth = input => {
32
32
  }
33
33
  return typeof input === 'number' ? `${input}px` : input;
34
34
  };
35
- const dialogHeight = input => {
35
+ export const dialogHeight = input => {
36
36
  if (!input) {
37
37
  return 'auto';
38
38
  }
@@ -53,7 +53,7 @@ const ModalDialog = props => {
53
53
  width = 'medium',
54
54
  shouldScrollInViewport = false,
55
55
  shouldCloseOnEscapePress,
56
- autoFocus: providedAutoFocus,
56
+ autoFocus,
57
57
  stackIndex,
58
58
  onClose,
59
59
  onCloseComplete,
@@ -69,10 +69,6 @@ const ModalDialog = props => {
69
69
  const id = useId();
70
70
  const titleId = `modal-dialog-title-${id}`;
71
71
  const defaultTestId = testId || 'modal-dialog';
72
- // https://product-fabric.atlassian.net/browse/DSP-24307
73
- // If flag and falsy, use true instead.
74
- // When we remove boolean `autoFocus`, we won't have to worry about this
75
- const autoFocus = !providedAutoFocus ? true : providedAutoFocus;
76
72
  useEffect(() => {
77
73
  // Modal dialogs can appear on top of iframe elements that are on another domain.
78
74
  // There is a Chrome bug where drag and drop in an element on top of a cross domain
@@ -84,7 +80,7 @@ const ModalDialog = props => {
84
80
 
85
81
  return combine(disableDraggingToCrossOriginIFramesForElement(), disableDraggingToCrossOriginIFramesForTextSelection(), disableDraggingToCrossOriginIFramesForExternal());
86
82
  }, []);
87
- useAutoFocus(typeof autoFocus === 'object' ? autoFocus : undefined,
83
+ useAutoFocus(autoFocus,
88
84
  // When a user supplies a ref to focus we enable this hook
89
85
  typeof autoFocus === 'object');
90
86
  const [motionRef, onMotionFinish] = useOnMotionFinish({
@@ -1,7 +1,24 @@
1
+
1
2
  ._152tze3t{inset-block-start:var(--ds-space-0,0)}
2
3
  ._18m91wug{overflow-y:auto}
3
4
  ._1bsbauwl{width:100vw}
5
+ ._1dg11kw7>form:only-child{flex-direction:inherit}
4
6
  ._1e02ze3t{inset-inline-start:var(--ds-space-0,0)}
7
+ ._1e0c1txw{display:flex}
8
+ ._1mq81kw7>form:only-child{display:inherit}
9
+ ._1q1l1bhr{--ds-elevation-surface-current:var(--ds-surface-overlay,#fff)}
10
+ ._1tke1kxc{min-height:100vh}
11
+ ._2lx21bp4{flex-direction:column}
5
12
  ._4t3i1kxc{height:100vh}
13
+ ._4t3i1osq{height:100%}
6
14
  ._8am5i4x0{-webkit-overflow-scrolling:touch}
7
- ._kqsw1n9t{position:fixed}
15
+ ._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
16
+ ._c71lglyw{max-height:none}
17
+ ._kqsw1n9t{position:fixed}
18
+ ._lcxv1wug{pointer-events:auto}
19
+ ._m01u1kw7>form:only-child{max-height:inherit}
20
+ ._syazi7uo{color:var(--ds-text,#292a2e)}._128mdkaa:focus-visible{outline-width:var(--ds-border-width-focused,2px)}
21
+ ._1ah3dkaa:focus-visible{outline-offset:var(--ds-border-width-focused,2px)}
22
+ ._mizu1v1w:focus-visible{outline-color:var(--ds-border-focused,#4688ec)}
23
+ ._ra3xnqa1:focus-visible{outline-style:solid}
24
+ @media (min-width:30rem){._bolhzwhf._bolhzwhf{max-height:calc(100vh - 119px)}._epkxfajl{border-radius:var(--ds-radius-small,3px)}._epkxpb1k{border-radius:var(--ds-radius-xlarge,9pt)}._zg7p130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}}