@atlaskit/dropdown-menu 16.1.4 → 16.2.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,23 @@
1
1
  # @atlaskit/dropdown-menu
2
2
 
3
+ ## 16.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#188621](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/188621)
8
+ [`94981059e9ba8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/94981059e9ba8) -
9
+ Added accessible label for MenuGroup in DropdownMenu
10
+ - Updated dependencies
11
+
12
+ ## 16.2.0
13
+
14
+ ### Minor Changes
15
+
16
+ - [#187681](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/187681)
17
+ [`64c917433bf89`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/64c917433bf89) -
18
+ Cleans up `platform_dst_dropdown_radio_default_selected_fix` feature gate. Default selected items
19
+ for radio group dropdowns are now correctly persisted.
20
+
3
21
  ## 16.1.4
4
22
 
5
23
  ### Patch Changes
@@ -101,7 +101,8 @@ var DropdownMenu = function DropdownMenu(_ref) {
101
101
  zIndex = _ref$zIndex === void 0 ? _constants.layers.modal() : _ref$zIndex,
102
102
  label = _ref.label,
103
103
  interactionName = _ref.interactionName,
104
- strategy = _ref.strategy;
104
+ strategy = _ref.strategy,
105
+ menuLabel = _ref.menuLabel;
105
106
  var _useControlledState = (0, _useControlled.default)(isOpen, function () {
106
107
  return defaultOpen;
107
108
  }),
@@ -331,7 +332,8 @@ var DropdownMenu = function DropdownMenu(_ref) {
331
332
  shouldRenderToParent: shouldRenderToParent || shouldFitContainer,
332
333
  isTriggeredUsingKeyboard: isTriggeredUsingKeyboard,
333
334
  autoFocus: autoFocus,
334
- testId: testId && "".concat(testId, "--menu-wrapper")
335
+ testId: testId && "".concat(testId, "--menu-wrapper"),
336
+ menuLabel: menuLabel
335
337
  }, children));
336
338
  }
337
339
  })));
@@ -54,7 +54,8 @@ var MenuWrapper = function MenuWrapper(_ref2) {
54
54
  spacing = _ref2.spacing,
55
55
  testId = _ref2.testId,
56
56
  isTriggeredUsingKeyboard = _ref2.isTriggeredUsingKeyboard,
57
- autoFocus = _ref2.autoFocus;
57
+ autoFocus = _ref2.autoFocus,
58
+ menuLabel = _ref2.menuLabel;
58
59
  var _useContext = (0, _react.useContext)(_focusManager.FocusManagerContext),
59
60
  menuItemRefs = _useContext.menuItemRefs;
60
61
  var closeOnMenuItemClick = function closeOnMenuItemClick(e) {
@@ -102,7 +103,8 @@ var MenuWrapper = function MenuWrapper(_ref2) {
102
103
  onClick: closeOnMenuItemClick,
103
104
  role: "menu",
104
105
  spacing: spacing,
105
- testId: testId && "".concat(testId, "--menu-group")
106
+ testId: testId && "".concat(testId, "--menu-group"),
107
+ menuLabel: menuLabel
106
108
  }, isLoading ? /*#__PURE__*/React.createElement(LoadingIndicator, {
107
109
  statusLabel: statusLabel,
108
110
  testId: testId && "".concat(testId, "--loading-indicator")
@@ -8,10 +8,8 @@ exports.default = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
10
  var _react = require("react");
11
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
11
  var _dropdownItemRadioGroup = require("../../radio/dropdown-item-radio-group");
13
12
  var _selectionStore = require("../context/selection-store");
14
- var _resetOptionsInGroup = _interopRequireDefault(require("../utils/reset-options-in-group"));
15
13
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
14
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
15
  function useRadioState(_ref) {
@@ -63,9 +61,7 @@ function useRadioState(_ref) {
63
61
  */
64
62
  if (persistedIsSelected === undefined) {
65
63
  var existing = getGroupState(group);
66
- var newGroupState = (0, _platformFeatureFlags.fg)('platform_dst_dropdown_radio_default_selected_fix') ? // FF on: only the current is changed
67
- _objectSpread(_objectSpread({}, existing), {}, (0, _defineProperty2.default)({}, id, defaultSelected || false)) : // FF off: everything else also gets set to false
68
- _objectSpread(_objectSpread({}, (0, _resetOptionsInGroup.default)(existing || {})), {}, (0, _defineProperty2.default)({}, id, defaultSelected || false));
64
+ var newGroupState = _objectSpread(_objectSpread({}, existing), {}, (0, _defineProperty2.default)({}, id, defaultSelected || false));
69
65
  setGroupState(group, newGroupState);
70
66
  }
71
67
  return [localIsSelected, setLocalState];
@@ -78,7 +78,8 @@ const DropdownMenu = ({
78
78
  zIndex = layers.modal(),
79
79
  label,
80
80
  interactionName,
81
- strategy
81
+ strategy,
82
+ menuLabel
82
83
  }) => {
83
84
  const [isLocalOpen, setLocalIsOpen] = useControlledState(isOpen, () => defaultOpen);
84
85
  const triggerRef = useRef(null);
@@ -303,7 +304,8 @@ const DropdownMenu = ({
303
304
  shouldRenderToParent: shouldRenderToParent || shouldFitContainer,
304
305
  isTriggeredUsingKeyboard: isTriggeredUsingKeyboard,
305
306
  autoFocus: autoFocus,
306
- testId: testId && `${testId}--menu-wrapper`
307
+ testId: testId && `${testId}--menu-wrapper`,
308
+ menuLabel: menuLabel
307
309
  }, children))
308
310
  })));
309
311
  };
@@ -43,7 +43,8 @@ const MenuWrapper = ({
43
43
  spacing,
44
44
  testId,
45
45
  isTriggeredUsingKeyboard,
46
- autoFocus
46
+ autoFocus,
47
+ menuLabel
47
48
  }) => {
48
49
  const {
49
50
  menuItemRefs
@@ -92,7 +93,8 @@ const MenuWrapper = ({
92
93
  onClick: closeOnMenuItemClick,
93
94
  role: "menu",
94
95
  spacing: spacing,
95
- testId: testId && `${testId}--menu-group`
96
+ testId: testId && `${testId}--menu-group`,
97
+ menuLabel: menuLabel
96
98
  }, isLoading ? /*#__PURE__*/React.createElement(LoadingIndicator, {
97
99
  statusLabel: statusLabel,
98
100
  testId: testId && `${testId}--loading-indicator`
@@ -1,8 +1,6 @@
1
1
  import { useCallback, useContext, useEffect, useState } from 'react';
2
- import { fg } from '@atlaskit/platform-feature-flags';
3
2
  import { RadioGroupContext } from '../../radio/dropdown-item-radio-group';
4
3
  import { SelectionStoreContext } from '../context/selection-store';
5
- import resetOptionsInGroup from '../utils/reset-options-in-group';
6
4
  function useRadioState({
7
5
  id,
8
6
  isSelected,
@@ -48,16 +46,9 @@ function useRadioState({
48
46
  */
49
47
  if (persistedIsSelected === undefined) {
50
48
  const existing = getGroupState(group);
51
- const newGroupState = fg('platform_dst_dropdown_radio_default_selected_fix') ?
52
- // FF on: only the current is changed
53
- {
49
+ const newGroupState = {
54
50
  ...existing,
55
51
  [id]: defaultSelected || false
56
- } :
57
- // FF off: everything else also gets set to false
58
- {
59
- ...resetOptionsInGroup(existing || {}),
60
- [id]: defaultSelected || false
61
52
  };
62
53
  setGroupState(group, newGroupState);
63
54
  }
@@ -93,7 +93,8 @@ var DropdownMenu = function DropdownMenu(_ref) {
93
93
  zIndex = _ref$zIndex === void 0 ? layers.modal() : _ref$zIndex,
94
94
  label = _ref.label,
95
95
  interactionName = _ref.interactionName,
96
- strategy = _ref.strategy;
96
+ strategy = _ref.strategy,
97
+ menuLabel = _ref.menuLabel;
97
98
  var _useControlledState = useControlledState(isOpen, function () {
98
99
  return defaultOpen;
99
100
  }),
@@ -323,7 +324,8 @@ var DropdownMenu = function DropdownMenu(_ref) {
323
324
  shouldRenderToParent: shouldRenderToParent || shouldFitContainer,
324
325
  isTriggeredUsingKeyboard: isTriggeredUsingKeyboard,
325
326
  autoFocus: autoFocus,
326
- testId: testId && "".concat(testId, "--menu-wrapper")
327
+ testId: testId && "".concat(testId, "--menu-wrapper"),
328
+ menuLabel: menuLabel
327
329
  }, children));
328
330
  }
329
331
  })));
@@ -45,7 +45,8 @@ var MenuWrapper = function MenuWrapper(_ref2) {
45
45
  spacing = _ref2.spacing,
46
46
  testId = _ref2.testId,
47
47
  isTriggeredUsingKeyboard = _ref2.isTriggeredUsingKeyboard,
48
- autoFocus = _ref2.autoFocus;
48
+ autoFocus = _ref2.autoFocus,
49
+ menuLabel = _ref2.menuLabel;
49
50
  var _useContext = useContext(FocusManagerContext),
50
51
  menuItemRefs = _useContext.menuItemRefs;
51
52
  var closeOnMenuItemClick = function closeOnMenuItemClick(e) {
@@ -93,7 +94,8 @@ var MenuWrapper = function MenuWrapper(_ref2) {
93
94
  onClick: closeOnMenuItemClick,
94
95
  role: "menu",
95
96
  spacing: spacing,
96
- testId: testId && "".concat(testId, "--menu-group")
97
+ testId: testId && "".concat(testId, "--menu-group"),
98
+ menuLabel: menuLabel
97
99
  }, isLoading ? /*#__PURE__*/React.createElement(LoadingIndicator, {
98
100
  statusLabel: statusLabel,
99
101
  testId: testId && "".concat(testId, "--loading-indicator")
@@ -3,10 +3,8 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
5
  import { useCallback, useContext, useEffect, useState } from 'react';
6
- import { fg } from '@atlaskit/platform-feature-flags';
7
6
  import { RadioGroupContext } from '../../radio/dropdown-item-radio-group';
8
7
  import { SelectionStoreContext } from '../context/selection-store';
9
- import resetOptionsInGroup from '../utils/reset-options-in-group';
10
8
  function useRadioState(_ref) {
11
9
  var id = _ref.id,
12
10
  isSelected = _ref.isSelected,
@@ -56,9 +54,7 @@ function useRadioState(_ref) {
56
54
  */
57
55
  if (persistedIsSelected === undefined) {
58
56
  var existing = getGroupState(group);
59
- var newGroupState = fg('platform_dst_dropdown_radio_default_selected_fix') ? // FF on: only the current is changed
60
- _objectSpread(_objectSpread({}, existing), {}, _defineProperty({}, id, defaultSelected || false)) : // FF off: everything else also gets set to false
61
- _objectSpread(_objectSpread({}, resetOptionsInGroup(existing || {})), {}, _defineProperty({}, id, defaultSelected || false));
57
+ var newGroupState = _objectSpread(_objectSpread({}, existing), {}, _defineProperty({}, id, defaultSelected || false));
62
58
  setGroupState(group, newGroupState);
63
59
  }
64
60
  return [localIsSelected, setLocalState];
@@ -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, strategy, }: DropdownMenuProps<T>) => React.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, menuLabel, }: DropdownMenuProps<T>) => React.JSX.Element;
13
13
  export default DropdownMenu;
@@ -7,5 +7,5 @@ import { type MenuWrapperProps } from '../../types';
7
7
  * if a CheckboxItem or RadioItem is clicked.
8
8
  * It also sets focus to the first menu item when opened.
9
9
  */
10
- declare const MenuWrapper: ({ children, isLoading, maxHeight, maxWidth, onClose, onUpdate, statusLabel, setInitialFocusRef, shouldRenderToParent, spacing, testId, isTriggeredUsingKeyboard, autoFocus, }: MenuWrapperProps) => JSX.Element;
10
+ declare const MenuWrapper: ({ children, isLoading, maxHeight, maxWidth, onClose, onUpdate, statusLabel, setInitialFocusRef, shouldRenderToParent, spacing, testId, isTriggeredUsingKeyboard, autoFocus, menuLabel, }: MenuWrapperProps) => JSX.Element;
11
11
  export default MenuWrapper;
@@ -181,6 +181,10 @@ interface InternalDropdownMenuProps<TriggerElement extends HTMLElement = any> {
181
181
  * The default is `fixed`.
182
182
  */
183
183
  strategy?: 'absolute' | 'fixed';
184
+ /**
185
+ * Provide an accessible label for the menu element for assistive technology.
186
+ */
187
+ menuLabel?: string;
184
188
  }
185
189
  type StandardDropdownMenuProps<TriggerElement extends HTMLElement = any> = InternalDropdownMenuProps<TriggerElement> & {
186
190
  shouldFitContainer?: false;
@@ -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, strategy, }: DropdownMenuProps<T>) => React.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, menuLabel, }: DropdownMenuProps<T>) => React.JSX.Element;
13
13
  export default DropdownMenu;
@@ -7,5 +7,5 @@ import { type MenuWrapperProps } from '../../types';
7
7
  * if a CheckboxItem or RadioItem is clicked.
8
8
  * It also sets focus to the first menu item when opened.
9
9
  */
10
- declare const MenuWrapper: ({ children, isLoading, maxHeight, maxWidth, onClose, onUpdate, statusLabel, setInitialFocusRef, shouldRenderToParent, spacing, testId, isTriggeredUsingKeyboard, autoFocus, }: MenuWrapperProps) => JSX.Element;
10
+ declare const MenuWrapper: ({ children, isLoading, maxHeight, maxWidth, onClose, onUpdate, statusLabel, setInitialFocusRef, shouldRenderToParent, spacing, testId, isTriggeredUsingKeyboard, autoFocus, menuLabel, }: MenuWrapperProps) => JSX.Element;
11
11
  export default MenuWrapper;
@@ -181,6 +181,10 @@ interface InternalDropdownMenuProps<TriggerElement extends HTMLElement = any> {
181
181
  * The default is `fixed`.
182
182
  */
183
183
  strategy?: 'absolute' | 'fixed';
184
+ /**
185
+ * Provide an accessible label for the menu element for assistive technology.
186
+ */
187
+ menuLabel?: string;
184
188
  }
185
189
  type StandardDropdownMenuProps<TriggerElement extends HTMLElement = any> = InternalDropdownMenuProps<TriggerElement> & {
186
190
  shouldFitContainer?: false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/dropdown-menu",
3
- "version": "16.1.4",
3
+ "version": "16.2.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/"
@@ -26,8 +26,8 @@
26
26
  "dependencies": {
27
27
  "@atlaskit/button": "^23.2.0",
28
28
  "@atlaskit/css": "^0.12.0",
29
- "@atlaskit/ds-lib": "^4.0.0",
30
- "@atlaskit/icon": "^27.3.0",
29
+ "@atlaskit/ds-lib": "^4.1.0",
30
+ "@atlaskit/icon": "^27.5.0",
31
31
  "@atlaskit/layering": "^3.0.0",
32
32
  "@atlaskit/menu": "^8.0.0",
33
33
  "@atlaskit/platform-feature-flags": "^1.1.0",
@@ -35,7 +35,7 @@
35
35
  "@atlaskit/primitives": "^14.10.0",
36
36
  "@atlaskit/spinner": "^18.0.0",
37
37
  "@atlaskit/theme": "^19.0.0",
38
- "@atlaskit/tokens": "^5.4.0",
38
+ "@atlaskit/tokens": "^5.6.0",
39
39
  "@atlaskit/visually-hidden": "^3.0.0",
40
40
  "@babel/runtime": "^7.0.0",
41
41
  "bind-event-listener": "^3.0.0"
@@ -57,7 +57,7 @@
57
57
  "@atlaskit/heading": "^5.2.0",
58
58
  "@atlaskit/link": "^3.2.0",
59
59
  "@atlaskit/lozenge": "^13.0.0",
60
- "@atlaskit/modal-dialog": "^14.2.0",
60
+ "@atlaskit/modal-dialog": "^14.3.0",
61
61
  "@atlaskit/section-message": "^8.2.0",
62
62
  "@atlaskit/textfield": "^8.0.0",
63
63
  "@atlaskit/toggle": "^15.0.0",
@@ -91,9 +91,6 @@
91
91
  },
92
92
  "platform_design_system_team_dropdown_return_focus": {
93
93
  "type": "boolean"
94
- },
95
- "platform_dst_dropdown_radio_default_selected_fix": {
96
- "type": "boolean"
97
94
  }
98
95
  },
99
96
  "techstack": {