@atlaskit/dropdown-menu 12.19.0 → 12.20.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,64 @@
1
1
  # @atlaskit/dropdown-menu
2
2
 
3
+ ## 12.20.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 12.20.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#151581](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/151581)
14
+ [`ce972f75db165`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ce972f75db165) - ##
15
+ New Feature: Configurable Popper Strategy
16
+
17
+ **Feature Overview:** The `@atlaskit/dropdown-menu` component now includes a new `strategy` prop,
18
+ providing developers with the ability to customize the positioning strategy of dropdowns. This
19
+ enhancement offers more control over how dropdown menus are rendered and positioned, accommodating
20
+ various layout needs.
21
+
22
+ **Usage:** The `strategy` prop can be set to either `'absolute'` or `'fixed'`, with the default
23
+ being `'fixed'`.
24
+
25
+ - **`'fixed'`:** Positions the dropdown relative to the browser's viewport. This ensures that the
26
+ dropdown remains in the same position regardless of page scrolling, making it ideal for
27
+ dropdowns that need to maintain a consistent position on the screen.
28
+
29
+ - **`'absolute'`:** Positions the dropdown relative to its closest positioned ancestor, which
30
+ allows the dropdown to move with the content as the page is scrolled or resized. This is useful
31
+ in scenarios where the dropdown should remain contextually attached to an element within a
32
+ scrollable area.
33
+
34
+ **Example Usage:**
35
+
36
+ ```jsx
37
+ import DropdownMenu from '@atlaskit/dropdown-menu';
38
+
39
+ const MyDropdown = () => (
40
+ <DropdownMenu
41
+ trigger="Options"
42
+ strategy="absolute" // Options are 'absolute' or 'fixed'
43
+ >
44
+ <DropdownMenu.Item>First option</DropdownMenu.Item>
45
+ <DropdownMenu.Item>Second option</DropdownMenu.Item>
46
+ </DropdownMenu>
47
+ );
48
+ ```
49
+
50
+ **Important Considerations:**
51
+
52
+ - When using the `shouldFitContainer` prop, the `strategy` cannot be set to `'fixed'`. In such
53
+ cases, the dropdown defaults to the `'absolute'` strategy to ensure proper rendering within the
54
+ container.
55
+ - The `strategy` prop provides additional flexibility, especially in complex layouts where precise
56
+ control over dropdown positioning is required. It allows the dropdown to adapt based on the
57
+ surrounding context or constraints, enhancing the component's versatility.
58
+ - This feature addresses the need for more adaptable positioning strategies, allowing for better
59
+ integration into varied UI designs and improving user experience by maintaining dropdown
60
+ visibility and accessibility.
61
+
3
62
  ## 12.19.0
4
63
 
5
64
  ### Minor Changes
@@ -99,7 +99,8 @@ var DropdownMenu = function DropdownMenu(_ref) {
99
99
  _ref$zIndex = _ref.zIndex,
100
100
  zIndex = _ref$zIndex === void 0 ? _constants.layers.modal() : _ref$zIndex,
101
101
  label = _ref.label,
102
- interactionName = _ref.interactionName;
102
+ interactionName = _ref.interactionName,
103
+ strategy = _ref.strategy;
103
104
  var _useControlledState = (0, _useControlled.default)(isOpen, function () {
104
105
  return defaultOpen;
105
106
  }),
@@ -245,9 +246,12 @@ var DropdownMenu = function DropdownMenu(_ref) {
245
246
  * types are satisfied.
246
247
  */
247
248
  var conditionalProps = shouldFitContainer ? {
248
- shouldFitContainer: shouldFitContainer
249
+ shouldFitContainer: shouldFitContainer,
250
+ // When shouldFitContainer is true, `fixed` positions are not allowed
251
+ strategy: strategy !== 'fixed' ? strategy : undefined
249
252
  } : {
250
- shouldRenderToParent: shouldRenderToParent
253
+ shouldRenderToParent: shouldRenderToParent,
254
+ strategy: strategy
251
255
  };
252
256
  return /*#__PURE__*/_react.default.createElement(_selectionStore.default, null, /*#__PURE__*/_react.default.createElement(_dropdownMenuContext.DropdownMenuProvider, {
253
257
  value: {
@@ -75,7 +75,8 @@ const DropdownMenu = ({
75
75
  trigger,
76
76
  zIndex = layers.modal(),
77
77
  label,
78
- interactionName
78
+ interactionName,
79
+ strategy
79
80
  }) => {
80
81
  const [isLocalOpen, setLocalIsOpen] = useControlledState(isOpen, () => defaultOpen);
81
82
  const triggerRef = useRef(null);
@@ -215,9 +216,12 @@ const DropdownMenu = ({
215
216
  * types are satisfied.
216
217
  */
217
218
  const conditionalProps = shouldFitContainer ? {
218
- shouldFitContainer
219
+ shouldFitContainer,
220
+ // When shouldFitContainer is true, `fixed` positions are not allowed
221
+ strategy: strategy !== 'fixed' ? strategy : undefined
219
222
  } : {
220
- shouldRenderToParent
223
+ shouldRenderToParent,
224
+ strategy
221
225
  };
222
226
  return /*#__PURE__*/React.createElement(SelectionStore, null, /*#__PURE__*/React.createElement(DropdownMenuProvider, {
223
227
  value: {
@@ -90,7 +90,8 @@ var DropdownMenu = function DropdownMenu(_ref) {
90
90
  _ref$zIndex = _ref.zIndex,
91
91
  zIndex = _ref$zIndex === void 0 ? layers.modal() : _ref$zIndex,
92
92
  label = _ref.label,
93
- interactionName = _ref.interactionName;
93
+ interactionName = _ref.interactionName,
94
+ strategy = _ref.strategy;
94
95
  var _useControlledState = useControlledState(isOpen, function () {
95
96
  return defaultOpen;
96
97
  }),
@@ -236,9 +237,12 @@ var DropdownMenu = function DropdownMenu(_ref) {
236
237
  * types are satisfied.
237
238
  */
238
239
  var conditionalProps = shouldFitContainer ? {
239
- shouldFitContainer: shouldFitContainer
240
+ shouldFitContainer: shouldFitContainer,
241
+ // When shouldFitContainer is true, `fixed` positions are not allowed
242
+ strategy: strategy !== 'fixed' ? strategy : undefined
240
243
  } : {
241
- shouldRenderToParent: shouldRenderToParent
244
+ shouldRenderToParent: shouldRenderToParent,
245
+ strategy: strategy
242
246
  };
243
247
  return /*#__PURE__*/React.createElement(SelectionStore, null, /*#__PURE__*/React.createElement(DropdownMenuProvider, {
244
248
  value: {
@@ -9,5 +9,5 @@ import type { DropdownMenuProps } from './types';
9
9
  * - [Code](https://atlassian.design/components/dropdown-menu/code)
10
10
  * - [Usage](https://atlassian.design/components/dropdown-menu/usage)
11
11
  */
12
- declare const DropdownMenu: <T extends HTMLElement = any>({ autoFocus, children, defaultOpen, isLoading, isOpen, onOpenChange, placement, shouldFitContainer, shouldFlip, shouldRenderToParent, returnFocusRef, spacing, statusLabel, testId, trigger, zIndex, label, interactionName, }: DropdownMenuProps<T>) => JSX.Element;
12
+ declare const DropdownMenu: <T extends HTMLElement = any>({ autoFocus, children, defaultOpen, isLoading, isOpen, onOpenChange, placement, shouldFitContainer, shouldFlip, shouldRenderToParent, returnFocusRef, spacing, statusLabel, testId, trigger, zIndex, label, interactionName, strategy, }: DropdownMenuProps<T>) => JSX.Element;
13
13
  export default DropdownMenu;
@@ -158,6 +158,11 @@ interface InternalDropdownMenuProps<TriggerElement extends HTMLElement = any> {
158
158
  * An optional name used to identify events for [React UFO (Unified Frontend Observability) press interactions](https://developer.atlassian.com/platform/ufo/react-ufo/react-ufo/getting-started/#quick-start--press-interactions). For more information, see [React UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
159
159
  */
160
160
  interactionName?: string;
161
+ /**
162
+ * This controls the positioning strategy to use. Can vary between `absolute` and `fixed`.
163
+ * The default is `fixed`.
164
+ */
165
+ strategy?: 'absolute' | 'fixed';
161
166
  }
162
167
  type StandardDropdownMenuProps<TriggerElement extends HTMLElement = any> = InternalDropdownMenuProps<TriggerElement> & {
163
168
  shouldFitContainer?: false;
@@ -165,6 +170,7 @@ type StandardDropdownMenuProps<TriggerElement extends HTMLElement = any> = Inter
165
170
  type ShouldFitContainerDropdownMenuProps<TriggerElement extends HTMLElement = any> = InternalDropdownMenuProps<TriggerElement> & {
166
171
  shouldFitContainer: true;
167
172
  shouldRenderToParent?: true;
173
+ strategy?: 'absolute';
168
174
  };
169
175
  export type DropdownMenuProps<TriggerElement extends HTMLElement = any> = StandardDropdownMenuProps<TriggerElement> | ShouldFitContainerDropdownMenuProps<TriggerElement>;
170
176
  export interface DropdownItemProps {
@@ -9,5 +9,5 @@ import type { DropdownMenuProps } from './types';
9
9
  * - [Code](https://atlassian.design/components/dropdown-menu/code)
10
10
  * - [Usage](https://atlassian.design/components/dropdown-menu/usage)
11
11
  */
12
- declare const DropdownMenu: <T extends HTMLElement = any>({ autoFocus, children, defaultOpen, isLoading, isOpen, onOpenChange, placement, shouldFitContainer, shouldFlip, shouldRenderToParent, returnFocusRef, spacing, statusLabel, testId, trigger, zIndex, label, interactionName, }: DropdownMenuProps<T>) => JSX.Element;
12
+ declare const DropdownMenu: <T extends HTMLElement = any>({ autoFocus, children, defaultOpen, isLoading, isOpen, onOpenChange, placement, shouldFitContainer, shouldFlip, shouldRenderToParent, returnFocusRef, spacing, statusLabel, testId, trigger, zIndex, label, interactionName, strategy, }: DropdownMenuProps<T>) => JSX.Element;
13
13
  export default DropdownMenu;
@@ -158,6 +158,11 @@ interface InternalDropdownMenuProps<TriggerElement extends HTMLElement = any> {
158
158
  * An optional name used to identify events for [React UFO (Unified Frontend Observability) press interactions](https://developer.atlassian.com/platform/ufo/react-ufo/react-ufo/getting-started/#quick-start--press-interactions). For more information, see [React UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
159
159
  */
160
160
  interactionName?: string;
161
+ /**
162
+ * This controls the positioning strategy to use. Can vary between `absolute` and `fixed`.
163
+ * The default is `fixed`.
164
+ */
165
+ strategy?: 'absolute' | 'fixed';
161
166
  }
162
167
  type StandardDropdownMenuProps<TriggerElement extends HTMLElement = any> = InternalDropdownMenuProps<TriggerElement> & {
163
168
  shouldFitContainer?: false;
@@ -165,6 +170,7 @@ type StandardDropdownMenuProps<TriggerElement extends HTMLElement = any> = Inter
165
170
  type ShouldFitContainerDropdownMenuProps<TriggerElement extends HTMLElement = any> = InternalDropdownMenuProps<TriggerElement> & {
166
171
  shouldFitContainer: true;
167
172
  shouldRenderToParent?: true;
173
+ strategy?: 'absolute';
168
174
  };
169
175
  export type DropdownMenuProps<TriggerElement extends HTMLElement = any> = StandardDropdownMenuProps<TriggerElement> | ShouldFitContainerDropdownMenuProps<TriggerElement>;
170
176
  export interface DropdownItemProps {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/dropdown-menu",
3
- "version": "12.19.0",
3
+ "version": "12.20.1",
4
4
  "description": "A dropdown menu displays a list of actions or options to a user.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -25,9 +25,9 @@
25
25
  "dependencies": {
26
26
  "@atlaskit/button": "^20.2.0",
27
27
  "@atlaskit/codemod-utils": "^4.2.0",
28
- "@atlaskit/ds-lib": "^3.0.0",
29
- "@atlaskit/icon": "^22.20.0",
30
- "@atlaskit/layering": "^0.5.0",
28
+ "@atlaskit/ds-lib": "^3.1.0",
29
+ "@atlaskit/icon": "^22.22.0",
30
+ "@atlaskit/layering": "^0.6.0",
31
31
  "@atlaskit/menu": "^2.12.0",
32
32
  "@atlaskit/platform-feature-flags": "^0.3.0",
33
33
  "@atlaskit/popup": "^1.28.0",