@atlaskit/dropdown-menu 12.18.4 → 12.18.6

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/checkbox/dropdown-item-checkbox-group.js +2 -2
  3. package/dist/cjs/checkbox/dropdown-item-checkbox.js +5 -2
  4. package/dist/cjs/dropdown-menu-item-group.js +2 -2
  5. package/dist/cjs/dropdown-menu-item.js +9 -4
  6. package/dist/cjs/dropdown-menu.js +6 -2
  7. package/dist/cjs/internal/components/focus-manager.js +39 -5
  8. package/dist/cjs/radio/dropdown-item-radio-group.js +2 -2
  9. package/dist/cjs/radio/dropdown-item-radio.js +5 -2
  10. package/dist/es2019/checkbox/dropdown-item-checkbox-group.js +1 -1
  11. package/dist/es2019/checkbox/dropdown-item-checkbox.js +4 -1
  12. package/dist/es2019/dropdown-menu-item-group.js +1 -1
  13. package/dist/es2019/dropdown-menu-item.js +8 -3
  14. package/dist/es2019/dropdown-menu.js +6 -2
  15. package/dist/es2019/internal/components/focus-manager.js +39 -7
  16. package/dist/es2019/radio/dropdown-item-radio-group.js +1 -1
  17. package/dist/es2019/radio/dropdown-item-radio.js +4 -1
  18. package/dist/esm/checkbox/dropdown-item-checkbox-group.js +1 -1
  19. package/dist/esm/checkbox/dropdown-item-checkbox.js +5 -2
  20. package/dist/esm/dropdown-menu-item-group.js +1 -1
  21. package/dist/esm/dropdown-menu-item.js +9 -4
  22. package/dist/esm/dropdown-menu.js +6 -2
  23. package/dist/esm/internal/components/focus-manager.js +39 -5
  24. package/dist/esm/radio/dropdown-item-radio-group.js +1 -1
  25. package/dist/esm/radio/dropdown-item-radio.js +5 -2
  26. package/dist/types/checkbox/dropdown-item-checkbox.d.ts +1 -1
  27. package/dist/types/dropdown-menu.d.ts +1 -1
  28. package/dist/types/internal/components/focus-manager.d.ts +1 -1
  29. package/dist/types/radio/dropdown-item-radio.d.ts +1 -1
  30. package/dist/types/types.d.ts +16 -0
  31. package/dist/types-ts4.5/checkbox/dropdown-item-checkbox.d.ts +1 -1
  32. package/dist/types-ts4.5/dropdown-menu.d.ts +1 -1
  33. package/dist/types-ts4.5/internal/components/focus-manager.d.ts +1 -1
  34. package/dist/types-ts4.5/radio/dropdown-item-radio.d.ts +1 -1
  35. package/dist/types-ts4.5/types.d.ts +16 -0
  36. package/package.json +5 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/dropdown-menu
2
2
 
3
+ ## 12.18.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`5ceb889d493ab`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5ceb889d493ab) -
8
+ Fix issue with Async loading of Dropdown Menu Items
9
+ - [#148281](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/148281)
10
+ [`3c4de48168ffe`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3c4de48168ffe) -
11
+ Update the import path of `useId*` from `@atlaskit/ds-lib`
12
+ - Updated dependencies
13
+
14
+ ## 12.18.5
15
+
16
+ ### Patch Changes
17
+
18
+ - [#148720](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/148720)
19
+ [`fcf151627c8de`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fcf151627c8de) -
20
+ Added interactionName to components in menu and dropdownmenu
21
+
3
22
  ## 12.18.4
4
23
 
5
24
  ### Patch Changes
@@ -8,7 +8,7 @@ exports.default = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
10
  var _react = _interopRequireDefault(require("react"));
11
- var _reactUid = require("@atlaskit/ds-lib/react-uid");
11
+ var _useId = require("@atlaskit/ds-lib/use-id");
12
12
  var _section = _interopRequireDefault(require("@atlaskit/menu/section"));
13
13
  var _groupTitle = _interopRequireDefault(require("../internal/components/group-title"));
14
14
  var _checkboxGroupContext = require("../internal/context/checkbox-group-context");
@@ -29,7 +29,7 @@ var DropdownItemCheckboxGroup = function DropdownItemCheckboxGroup(_ref) {
29
29
  testId = _ref.testId,
30
30
  title = _ref.title,
31
31
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
32
- var uid = (0, _reactUid.useId)();
32
+ var uid = (0, _useId.useId)();
33
33
  var titleId = "dropdown-menu-item-checkbox-group-title-".concat(uid);
34
34
  return /*#__PURE__*/_react.default.createElement(_checkboxGroupContext.CheckboxGroupContext.Provider, {
35
35
  value: id
@@ -13,10 +13,11 @@ var _react = _interopRequireWildcard(require("react"));
13
13
  var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
14
14
  var _menu = require("@atlaskit/menu");
15
15
  var _buttonItem = _interopRequireDefault(require("@atlaskit/menu/button-item"));
16
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
17
  var _checkboxIcon = _interopRequireDefault(require("../internal/components/checkbox-icon"));
17
18
  var _useCheckboxState3 = _interopRequireDefault(require("../internal/hooks/use-checkbox-state"));
18
19
  var _useRegisterItemWithFocusManager = _interopRequireDefault(require("../internal/hooks/use-register-item-with-focus-manager"));
19
- var _excluded = ["children", "defaultSelected", "description", "id", "isDisabled", "isSelected", "onClick", "shouldDescriptionWrap", "shouldTitleWrap", "testId"];
20
+ var _excluded = ["children", "defaultSelected", "description", "id", "isDisabled", "isSelected", "onClick", "shouldDescriptionWrap", "shouldTitleWrap", "testId", "interactionName"];
20
21
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
21
22
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
22
23
  /**
@@ -42,6 +43,7 @@ var DropdownItemCheckbox = function DropdownItemCheckbox(_ref) {
42
43
  _ref$shouldTitleWrap = _ref.shouldTitleWrap,
43
44
  shouldTitleWrap = _ref$shouldTitleWrap === void 0 ? true : _ref$shouldTitleWrap,
44
45
  testId = _ref.testId,
46
+ interactionName = _ref.interactionName,
45
47
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
46
48
  if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production' && typeof isSelected !== 'undefined' && typeof defaultSelected !== 'undefined') {
47
49
  // eslint-disable-next-line no-console
@@ -79,7 +81,8 @@ var DropdownItemCheckbox = function DropdownItemCheckbox(_ref) {
79
81
  shouldDescriptionWrap: shouldDescriptionWrap,
80
82
  shouldTitleWrap: shouldTitleWrap,
81
83
  testId: testId
82
- // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
84
+ }, (0, _platformFeatureFlags.fg)('platform_button_item-add-ufo-metrics') && {
85
+ interactionName: interactionName
83
86
  }, rest), children));
84
87
  };
85
88
  var _default = exports.default = DropdownItemCheckbox;
@@ -9,7 +9,7 @@ exports.default = void 0;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
10
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
11
  var _react = _interopRequireWildcard(require("react"));
12
- var _reactUid = require("@atlaskit/ds-lib/react-uid");
12
+ var _useId = require("@atlaskit/ds-lib/use-id");
13
13
  var _menu = require("@atlaskit/menu");
14
14
  var _groupTitle = _interopRequireDefault(require("./internal/components/group-title"));
15
15
  var _excluded = ["children", "id", "isList", "isScrollable", "title", "testId", "hasSeparator", "overrides"];
@@ -31,7 +31,7 @@ var DropdownMenuItemGroup = /*#__PURE__*/(0, _react.forwardRef)(function (_ref,
31
31
  hasSeparator = _ref.hasSeparator,
32
32
  overrides = _ref.overrides,
33
33
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
34
- var uid = (0, _reactUid.useId)();
34
+ var uid = (0, _useId.useId)();
35
35
  var titleId = "dropdown-menu-item-group-title-".concat(uid);
36
36
  return /*#__PURE__*/_react.default.createElement(_menu.Section, (0, _extends2.default)({
37
37
  id: id,
@@ -13,8 +13,9 @@ var _mergeRefs = _interopRequireDefault(require("@atlaskit/ds-lib/merge-refs"));
13
13
  var _buttonItem = _interopRequireDefault(require("@atlaskit/menu/button-item"));
14
14
  var _customItem = _interopRequireDefault(require("@atlaskit/menu/custom-item"));
15
15
  var _linkItem = _interopRequireDefault(require("@atlaskit/menu/link-item"));
16
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
17
  var _useRegisterItemWithFocusManager = _interopRequireDefault(require("./internal/hooks/use-register-item-with-focus-manager"));
17
- var _excluded = ["children", "component", "description", "elemAfter", "elemBefore", "href", "isDisabled", "isSelected", "onClick", "rel", "shouldDescriptionWrap", "shouldTitleWrap", "target", "testId", "UNSAFE_shouldDisableRouterLink", "returnFocusRef"];
18
+ var _excluded = ["children", "component", "description", "elemAfter", "elemBefore", "href", "isDisabled", "isSelected", "onClick", "rel", "shouldDescriptionWrap", "shouldTitleWrap", "target", "testId", "UNSAFE_shouldDisableRouterLink", "returnFocusRef", "interactionName"];
18
19
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
19
20
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
20
21
  /**
@@ -45,6 +46,7 @@ var DropdownMenuItem = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref)
45
46
  testId = _ref.testId,
46
47
  UNSAFE_shouldDisableRouterLink = _ref.UNSAFE_shouldDisableRouterLink,
47
48
  returnFocusRef = _ref.returnFocusRef,
49
+ interactionName = _ref.interactionName,
48
50
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
49
51
  var itemRef = (0, _useRegisterItemWithFocusManager.default)();
50
52
  var handleItemClick = (0, _react.useCallback)(function (event) {
@@ -75,7 +77,8 @@ var DropdownMenuItem = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref)
75
77
  ,
76
78
  target: target,
77
79
  rel: rel
78
- // DSP-13312 TODO: remove spread props in future major release
80
+ }, (0, _platformFeatureFlags.fg)('platform_button_item-add-ufo-metrics') && {
81
+ interactionName: interactionName
79
82
  }, rest), children);
80
83
  } else if (href) {
81
84
  return /*#__PURE__*/_react.default.createElement(_linkItem.default, (0, _extends2.default)({
@@ -94,7 +97,8 @@ var DropdownMenuItem = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref)
94
97
  target: target,
95
98
  testId: testId,
96
99
  UNSAFE_shouldDisableRouterLink: UNSAFE_shouldDisableRouterLink
97
- // DSP-13312 TODO: remove spread props in future major release
100
+ }, (0, _platformFeatureFlags.fg)('platform_button_item-add-ufo-metrics') && {
101
+ interactionName: interactionName
98
102
  }, rest), children);
99
103
  } else {
100
104
  return /*#__PURE__*/_react.default.createElement(_buttonItem.default, (0, _extends2.default)({
@@ -115,7 +119,8 @@ var DropdownMenuItem = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref)
115
119
  ,
116
120
  target: target,
117
121
  rel: rel
118
- // DSP-13312 TODO: remove spread props in future major release
122
+ }, (0, _platformFeatureFlags.fg)('platform_button_item-add-ufo-metrics') && {
123
+ interactionName: interactionName
119
124
  }, rest), children);
120
125
  }
121
126
  });
@@ -19,6 +19,7 @@ var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
19
19
  var _useControlled = _interopRequireDefault(require("@atlaskit/ds-lib/use-controlled"));
20
20
  var _useFocusEvent = _interopRequireDefault(require("@atlaskit/ds-lib/use-focus-event"));
21
21
  var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/glyph/chevron-down"));
22
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
22
23
  var _popup = _interopRequireDefault(require("@atlaskit/popup"));
23
24
  var _constants = require("@atlaskit/theme/constants");
24
25
  var _focusManager = _interopRequireDefault(require("./internal/components/focus-manager"));
@@ -97,7 +98,8 @@ var DropdownMenu = function DropdownMenu(_ref) {
97
98
  _trigger = _ref.trigger,
98
99
  _ref$zIndex = _ref.zIndex,
99
100
  zIndex = _ref$zIndex === void 0 ? _constants.layers.modal() : _ref$zIndex,
100
- label = _ref.label;
101
+ label = _ref.label,
102
+ interactionName = _ref.interactionName;
101
103
  var _useControlledState = (0, _useControlled.default)(isOpen, function () {
102
104
  return defaultOpen;
103
105
  }),
@@ -146,7 +148,7 @@ var DropdownMenu = function DropdownMenu(_ref) {
146
148
  isOpen: newValue,
147
149
  event: event
148
150
  });
149
- }, [itemRef, onOpenChange, isLocalOpen, setLocalIsOpen]);
151
+ }, [isLocalOpen, setLocalIsOpen, onOpenChange, itemRef]);
150
152
  var handleOnClose = (0, _react.useCallback)(function (event, currentLevel) {
151
153
  var _event$target, _event$target$closest;
152
154
  if (event.key !== 'Escape' && event.key !== 'Tab' && (_event$target = event.target) !== null && _event$target !== void 0 && (_event$target$closest = _event$target.closest) !== null && _event$target$closest !== void 0 && _event$target$closest.call(_event$target, "[id^=".concat(_useGeneratedId.PREFIX, "] [aria-haspopup]"))) {
@@ -291,6 +293,8 @@ var DropdownMenu = function DropdownMenu(_ref) {
291
293
  onClick: handleTriggerClicked,
292
294
  testId: testId && "".concat(testId, "--trigger"),
293
295
  "aria-label": label
296
+ }, (0, _platformFeatureFlags.fg)('platform_button_item-add-ufo-metrics') && {
297
+ interactionName: interactionName
294
298
  }), _trigger);
295
299
  },
296
300
  content: function content(_ref3) {
@@ -18,7 +18,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
18
18
  *
19
19
  * Context provider which maintains the list of focusable elements and a method to
20
20
  * register new menu items.
21
- * This list drives the keyboard navgation of the menu.
21
+ * This list drives the keyboard navigation of the menu.
22
22
  *
23
23
  */
24
24
  var FocusManagerContext = exports.FocusManagerContext = /*#__PURE__*/(0, _react.createContext)({
@@ -33,15 +33,16 @@ var FocusManager = function FocusManager(_ref) {
33
33
  var children = _ref.children,
34
34
  onClose = _ref.onClose;
35
35
  var menuItemRefs = (0, _react.useRef)([]);
36
+ var registerRefCalls = (0, _react.useRef)(0);
36
37
  var registerRef = (0, _react.useCallback)(function (ref) {
37
- if (ref && !menuItemRefs.current.includes(ref)) {
38
- menuItemRefs.current.push(ref);
39
- }
38
+ return upsertRefAtFirstPosition(ref, menuItemRefs, registerRefCalls);
40
39
  }, []);
41
40
  var _UNSAFE_useLayering = (0, _layering.UNSAFE_useLayering)(),
42
41
  isLayerDisabled = _UNSAFE_useLayering.isLayerDisabled;
43
- // Intentionally rebinding on each render
44
42
  (0, _react.useEffect)(function () {
43
+ // Intentionally reset count on each render
44
+ registerRefCalls.current = 0;
45
+ // Intentionally rebinding on each render
45
46
  return (0, _bindEventListener.bind)(window, {
46
47
  type: 'keydown',
47
48
  listener: (0, _handleFocus.default)(menuItemRefs.current, isLayerDisabled, onClose)
@@ -55,4 +56,37 @@ var FocusManager = function FocusManager(_ref) {
55
56
  value: contextValue
56
57
  }, children);
57
58
  };
59
+
60
+ /**
61
+ * Insert the ref at the call position in the array.
62
+ * If the ref is already in the array, move it to the call position.
63
+ * If the call position is after the current position, ignore the call.
64
+ *
65
+ * @param ref
66
+ * @param menuItemRefs
67
+ * @param registerRefCalls
68
+ */
69
+ function upsertRefAtFirstPosition(ref, menuItemRefs, registerRefCalls) {
70
+ var positionOnCall = registerRefCalls.current++;
71
+
72
+ // Add the ref to the correct position
73
+ if (!menuItemRefs.current.includes(ref)) {
74
+ menuItemRefs.current.splice(positionOnCall, 0, ref);
75
+ return;
76
+ }
77
+ var positionCurrent = menuItemRefs.current.indexOf(ref);
78
+ if (positionOnCall === positionCurrent) {
79
+ // No change needed
80
+ return;
81
+ }
82
+ if (positionOnCall > positionCurrent) {
83
+ // Ignore and so keep the count the same
84
+ registerRefCalls.current--;
85
+ return;
86
+ }
87
+
88
+ // Update the position of the ref in the array
89
+ menuItemRefs.current.splice(positionCurrent, 1);
90
+ menuItemRefs.current.splice(positionOnCall, 0, ref);
91
+ }
58
92
  var _default = exports.default = FocusManager;
@@ -12,7 +12,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
12
12
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
13
  var _react = _interopRequireWildcard(require("react"));
14
14
  var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
15
- var _reactUid = require("@atlaskit/ds-lib/react-uid");
15
+ var _useId = require("@atlaskit/ds-lib/use-id");
16
16
  var _menu = require("@atlaskit/menu");
17
17
  var _groupTitle = _interopRequireDefault(require("../internal/components/group-title"));
18
18
  var _selectionStore = require("../internal/context/selection-store");
@@ -51,7 +51,7 @@ var DropdownItemRadioGroup = function DropdownItemRadioGroup(_ref) {
51
51
  var _useContext = (0, _react.useContext)(_selectionStore.SelectionStoreContext),
52
52
  setGroupState = _useContext.setGroupState,
53
53
  getGroupState = _useContext.getGroupState;
54
- var uid = (0, _reactUid.useId)();
54
+ var uid = (0, _useId.useId)();
55
55
  var titleId = "dropdown-menu-item-radio-group-title-".concat(uid);
56
56
 
57
57
  /**
@@ -13,11 +13,12 @@ var _react = _interopRequireWildcard(require("react"));
13
13
  var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
14
14
  var _menu = require("@atlaskit/menu");
15
15
  var _buttonItem = _interopRequireDefault(require("@atlaskit/menu/button-item"));
16
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
17
  var _radioIcon = _interopRequireDefault(require("../internal/components/radio-icon"));
17
18
  var _useRadioState3 = _interopRequireDefault(require("../internal/hooks/use-radio-state"));
18
19
  var _useRegisterItemWithFocusManager = _interopRequireDefault(require("../internal/hooks/use-register-item-with-focus-manager"));
19
20
  var _isVoiceOverSupported = _interopRequireDefault(require("../internal/utils/is-voice-over-supported"));
20
- var _excluded = ["children", "defaultSelected", "testId", "id", "title", "description", "isDisabled", "isSelected", "onClick", "shouldDescriptionWrap", "shouldTitleWrap"];
21
+ var _excluded = ["children", "defaultSelected", "testId", "id", "title", "description", "isDisabled", "isSelected", "onClick", "shouldDescriptionWrap", "shouldTitleWrap", "interactionName"];
21
22
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
22
23
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
23
24
  /**
@@ -44,6 +45,7 @@ var DropdownItemRadio = function DropdownItemRadio(_ref) {
44
45
  shouldDescriptionWrap = _ref$shouldDescriptio === void 0 ? true : _ref$shouldDescriptio,
45
46
  _ref$shouldTitleWrap = _ref.shouldTitleWrap,
46
47
  shouldTitleWrap = _ref$shouldTitleWrap === void 0 ? true : _ref$shouldTitleWrap,
48
+ interactionName = _ref.interactionName,
47
49
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
48
50
  if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production' && typeof isSelected !== 'undefined' && typeof defaultSelected !== 'undefined') {
49
51
  // eslint-disable-next-line no-console
@@ -86,7 +88,8 @@ var DropdownItemRadio = function DropdownItemRadio(_ref) {
86
88
  // @ts-expect-error
87
89
  ,
88
90
  title: title
89
- // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
91
+ }, (0, _platformFeatureFlags.fg)('platform_button_item-add-ufo-metrics') && {
92
+ interactionName: interactionName
90
93
  }, rest), children));
91
94
  };
92
95
  var _default = exports.default = DropdownItemRadio;
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
- import { useId } from '@atlaskit/ds-lib/react-uid';
3
+ import { useId } from '@atlaskit/ds-lib/use-id';
4
4
  import Section from '@atlaskit/menu/section';
5
5
  import GroupTitle from '../internal/components/group-title';
6
6
  import { CheckboxGroupContext } from '../internal/context/checkbox-group-context';
@@ -3,6 +3,7 @@ import React, { useCallback } from 'react';
3
3
  import noop from '@atlaskit/ds-lib/noop';
4
4
  import { SELECTION_STYLE_CONTEXT_DO_NOT_USE } from '@atlaskit/menu';
5
5
  import ButtonItem from '@atlaskit/menu/button-item';
6
+ import { fg } from '@atlaskit/platform-feature-flags';
6
7
  import CheckboxIcon from '../internal/components/checkbox-icon';
7
8
  import useCheckboxState from '../internal/hooks/use-checkbox-state';
8
9
  import useRegisterItemWithFocusManager from '../internal/hooks/use-register-item-with-focus-manager';
@@ -26,6 +27,7 @@ const DropdownItemCheckbox = ({
26
27
  shouldDescriptionWrap = true,
27
28
  shouldTitleWrap = true,
28
29
  testId,
30
+ interactionName,
29
31
  // DSP-13312 TODO: remove spread props in future major release
30
32
  ...rest
31
33
  }) => {
@@ -60,7 +62,8 @@ const DropdownItemCheckbox = ({
60
62
  shouldDescriptionWrap: shouldDescriptionWrap,
61
63
  shouldTitleWrap: shouldTitleWrap,
62
64
  testId: testId
63
- // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
65
+ }, fg('platform_button_item-add-ufo-metrics') && {
66
+ interactionName
64
67
  }, rest), children));
65
68
  };
66
69
  export default DropdownItemCheckbox;
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { forwardRef } from 'react';
3
- import { useId } from '@atlaskit/ds-lib/react-uid';
3
+ import { useId } from '@atlaskit/ds-lib/use-id';
4
4
  import { Section } from '@atlaskit/menu';
5
5
  import GroupTitle from './internal/components/group-title';
6
6
 
@@ -4,6 +4,7 @@ import mergeRefs from '@atlaskit/ds-lib/merge-refs';
4
4
  import ButtonItem from '@atlaskit/menu/button-item';
5
5
  import CustomItem from '@atlaskit/menu/custom-item';
6
6
  import LinkItem from '@atlaskit/menu/link-item';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import useRegisterItemWithFocusManager from './internal/hooks/use-register-item-with-focus-manager';
8
9
  /**
9
10
  * __Dropdown menu item__
@@ -31,6 +32,7 @@ const DropdownMenuItem = /*#__PURE__*/forwardRef(({
31
32
  testId,
32
33
  UNSAFE_shouldDisableRouterLink,
33
34
  returnFocusRef,
35
+ interactionName,
34
36
  ...rest
35
37
  }, ref) => {
36
38
  const itemRef = useRegisterItemWithFocusManager();
@@ -62,7 +64,8 @@ const DropdownMenuItem = /*#__PURE__*/forwardRef(({
62
64
  ,
63
65
  target: target,
64
66
  rel: rel
65
- // DSP-13312 TODO: remove spread props in future major release
67
+ }, fg('platform_button_item-add-ufo-metrics') && {
68
+ interactionName
66
69
  }, rest), children);
67
70
  } else if (href) {
68
71
  return /*#__PURE__*/React.createElement(LinkItem, _extends({
@@ -81,7 +84,8 @@ const DropdownMenuItem = /*#__PURE__*/forwardRef(({
81
84
  target: target,
82
85
  testId: testId,
83
86
  UNSAFE_shouldDisableRouterLink: UNSAFE_shouldDisableRouterLink
84
- // DSP-13312 TODO: remove spread props in future major release
87
+ }, fg('platform_button_item-add-ufo-metrics') && {
88
+ interactionName
85
89
  }, rest), children);
86
90
  } else {
87
91
  return /*#__PURE__*/React.createElement(ButtonItem, _extends({
@@ -102,7 +106,8 @@ const DropdownMenuItem = /*#__PURE__*/forwardRef(({
102
106
  ,
103
107
  target: target,
104
108
  rel: rel
105
- // DSP-13312 TODO: remove spread props in future major release
109
+ }, fg('platform_button_item-add-ufo-metrics') && {
110
+ interactionName
106
111
  }, rest), children);
107
112
  }
108
113
  });
@@ -8,6 +8,7 @@ import noop from '@atlaskit/ds-lib/noop';
8
8
  import useControlledState from '@atlaskit/ds-lib/use-controlled';
9
9
  import useFocus from '@atlaskit/ds-lib/use-focus-event';
10
10
  import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
11
+ import { fg } from '@atlaskit/platform-feature-flags';
11
12
  import Popup from '@atlaskit/popup';
12
13
  // eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
13
14
  import { gridSize as gridSizeFn, layers } from '@atlaskit/theme/constants';
@@ -73,7 +74,8 @@ const DropdownMenu = ({
73
74
  testId,
74
75
  trigger,
75
76
  zIndex = layers.modal(),
76
- label
77
+ label,
78
+ interactionName
77
79
  }) => {
78
80
  const [isLocalOpen, setLocalIsOpen] = useControlledState(isOpen, () => defaultOpen);
79
81
  const triggerRef = useRef(null);
@@ -115,7 +117,7 @@ const DropdownMenu = ({
115
117
  isOpen: newValue,
116
118
  event
117
119
  });
118
- }, [itemRef, onOpenChange, isLocalOpen, setLocalIsOpen]);
120
+ }, [isLocalOpen, setLocalIsOpen, onOpenChange, itemRef]);
119
121
  const handleOnClose = useCallback((event, currentLevel) => {
120
122
  var _event$target, _event$target$closest;
121
123
  if (event.key !== 'Escape' && event.key !== 'Tab' && (_event$target = event.target) !== null && _event$target !== void 0 && (_event$target$closest = _event$target.closest) !== null && _event$target$closest !== void 0 && _event$target$closest.call(_event$target, `[id^=${PREFIX}] [aria-haspopup]`)) {
@@ -264,6 +266,8 @@ const DropdownMenu = ({
264
266
  onClick: handleTriggerClicked,
265
267
  testId: testId && `${testId}--trigger`,
266
268
  "aria-label": label
269
+ }, fg('platform_button_item-add-ufo-metrics') && {
270
+ interactionName
267
271
  }), trigger);
268
272
  },
269
273
  content: ({
@@ -9,7 +9,7 @@ import handleFocus from '../utils/handle-focus';
9
9
  *
10
10
  * Context provider which maintains the list of focusable elements and a method to
11
11
  * register new menu items.
12
- * This list drives the keyboard navgation of the menu.
12
+ * This list drives the keyboard navigation of the menu.
13
13
  *
14
14
  */
15
15
  export const FocusManagerContext = /*#__PURE__*/createContext({
@@ -25,16 +25,15 @@ const FocusManager = ({
25
25
  onClose
26
26
  }) => {
27
27
  const menuItemRefs = useRef([]);
28
- const registerRef = useCallback(ref => {
29
- if (ref && !menuItemRefs.current.includes(ref)) {
30
- menuItemRefs.current.push(ref);
31
- }
32
- }, []);
28
+ const registerRefCalls = useRef(0);
29
+ const registerRef = useCallback(ref => upsertRefAtFirstPosition(ref, menuItemRefs, registerRefCalls), []);
33
30
  const {
34
31
  isLayerDisabled
35
32
  } = UNSAFE_useLayering();
36
- // Intentionally rebinding on each render
37
33
  useEffect(() => {
34
+ // Intentionally reset count on each render
35
+ registerRefCalls.current = 0;
36
+ // Intentionally rebinding on each render
38
37
  return bind(window, {
39
38
  type: 'keydown',
40
39
  listener: handleFocus(menuItemRefs.current, isLayerDisabled, onClose)
@@ -48,4 +47,37 @@ const FocusManager = ({
48
47
  value: contextValue
49
48
  }, children);
50
49
  };
50
+
51
+ /**
52
+ * Insert the ref at the call position in the array.
53
+ * If the ref is already in the array, move it to the call position.
54
+ * If the call position is after the current position, ignore the call.
55
+ *
56
+ * @param ref
57
+ * @param menuItemRefs
58
+ * @param registerRefCalls
59
+ */
60
+ function upsertRefAtFirstPosition(ref, menuItemRefs, registerRefCalls) {
61
+ const positionOnCall = registerRefCalls.current++;
62
+
63
+ // Add the ref to the correct position
64
+ if (!menuItemRefs.current.includes(ref)) {
65
+ menuItemRefs.current.splice(positionOnCall, 0, ref);
66
+ return;
67
+ }
68
+ const positionCurrent = menuItemRefs.current.indexOf(ref);
69
+ if (positionOnCall === positionCurrent) {
70
+ // No change needed
71
+ return;
72
+ }
73
+ if (positionOnCall > positionCurrent) {
74
+ // Ignore and so keep the count the same
75
+ registerRefCalls.current--;
76
+ return;
77
+ }
78
+
79
+ // Update the position of the ref in the array
80
+ menuItemRefs.current.splice(positionCurrent, 1);
81
+ menuItemRefs.current.splice(positionOnCall, 0, ref);
82
+ }
51
83
  export default FocusManager;
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { createContext, useContext, useState } from 'react';
3
3
  import noop from '@atlaskit/ds-lib/noop';
4
- import { useId } from '@atlaskit/ds-lib/react-uid';
4
+ import { useId } from '@atlaskit/ds-lib/use-id';
5
5
  import { Section } from '@atlaskit/menu';
6
6
  import GroupTitle from '../internal/components/group-title';
7
7
  import { SelectionStoreContext } from '../internal/context/selection-store';
@@ -3,6 +3,7 @@ import React, { useCallback } from 'react';
3
3
  import noop from '@atlaskit/ds-lib/noop';
4
4
  import { SELECTION_STYLE_CONTEXT_DO_NOT_USE } from '@atlaskit/menu';
5
5
  import ButtonItem from '@atlaskit/menu/button-item';
6
+ import { fg } from '@atlaskit/platform-feature-flags';
6
7
  import RadioIcon from '../internal/components/radio-icon';
7
8
  import useRadioState from '../internal/hooks/use-radio-state';
8
9
  import useRegisterItemWithFocusManager from '../internal/hooks/use-register-item-with-focus-manager';
@@ -28,6 +29,7 @@ const DropdownItemRadio = ({
28
29
  onClick: providedOnClick = noop,
29
30
  shouldDescriptionWrap = true,
30
31
  shouldTitleWrap = true,
32
+ interactionName,
31
33
  // DSP-13312 TODO: remove spread props in future major release
32
34
  ...rest
33
35
  }) => {
@@ -67,7 +69,8 @@ const DropdownItemRadio = ({
67
69
  // @ts-expect-error
68
70
  ,
69
71
  title: title
70
- // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
72
+ }, fg('platform_button_item-add-ufo-metrics') && {
73
+ interactionName
71
74
  }, rest), children));
72
75
  };
73
76
  export default DropdownItemRadio;
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["children", "hasSeparator", "id", "isList", "isScrollable", "overrides", "testId", "title"];
4
4
  import React from 'react';
5
- import { useId } from '@atlaskit/ds-lib/react-uid';
5
+ import { useId } from '@atlaskit/ds-lib/use-id';
6
6
  import Section from '@atlaskit/menu/section';
7
7
  import GroupTitle from '../internal/components/group-title';
8
8
  import { CheckboxGroupContext } from '../internal/context/checkbox-group-context';
@@ -1,11 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["children", "defaultSelected", "description", "id", "isDisabled", "isSelected", "onClick", "shouldDescriptionWrap", "shouldTitleWrap", "testId"];
4
+ var _excluded = ["children", "defaultSelected", "description", "id", "isDisabled", "isSelected", "onClick", "shouldDescriptionWrap", "shouldTitleWrap", "testId", "interactionName"];
5
5
  import React, { useCallback } from 'react';
6
6
  import noop from '@atlaskit/ds-lib/noop';
7
7
  import { SELECTION_STYLE_CONTEXT_DO_NOT_USE } from '@atlaskit/menu';
8
8
  import ButtonItem from '@atlaskit/menu/button-item';
9
+ import { fg } from '@atlaskit/platform-feature-flags';
9
10
  import CheckboxIcon from '../internal/components/checkbox-icon';
10
11
  import useCheckboxState from '../internal/hooks/use-checkbox-state';
11
12
  import useRegisterItemWithFocusManager from '../internal/hooks/use-register-item-with-focus-manager';
@@ -32,6 +33,7 @@ var DropdownItemCheckbox = function DropdownItemCheckbox(_ref) {
32
33
  _ref$shouldTitleWrap = _ref.shouldTitleWrap,
33
34
  shouldTitleWrap = _ref$shouldTitleWrap === void 0 ? true : _ref$shouldTitleWrap,
34
35
  testId = _ref.testId,
36
+ interactionName = _ref.interactionName,
35
37
  rest = _objectWithoutProperties(_ref, _excluded);
36
38
  if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production' && typeof isSelected !== 'undefined' && typeof defaultSelected !== 'undefined') {
37
39
  // eslint-disable-next-line no-console
@@ -69,7 +71,8 @@ var DropdownItemCheckbox = function DropdownItemCheckbox(_ref) {
69
71
  shouldDescriptionWrap: shouldDescriptionWrap,
70
72
  shouldTitleWrap: shouldTitleWrap,
71
73
  testId: testId
72
- // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
74
+ }, fg('platform_button_item-add-ufo-metrics') && {
75
+ interactionName: interactionName
73
76
  }, rest), children));
74
77
  };
75
78
  export default DropdownItemCheckbox;
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["children", "id", "isList", "isScrollable", "title", "testId", "hasSeparator", "overrides"];
4
4
  import React, { forwardRef } from 'react';
5
- import { useId } from '@atlaskit/ds-lib/react-uid';
5
+ import { useId } from '@atlaskit/ds-lib/use-id';
6
6
  import { Section } from '@atlaskit/menu';
7
7
  import GroupTitle from './internal/components/group-title';
8
8
 
@@ -1,11 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["children", "component", "description", "elemAfter", "elemBefore", "href", "isDisabled", "isSelected", "onClick", "rel", "shouldDescriptionWrap", "shouldTitleWrap", "target", "testId", "UNSAFE_shouldDisableRouterLink", "returnFocusRef"];
3
+ var _excluded = ["children", "component", "description", "elemAfter", "elemBefore", "href", "isDisabled", "isSelected", "onClick", "rel", "shouldDescriptionWrap", "shouldTitleWrap", "target", "testId", "UNSAFE_shouldDisableRouterLink", "returnFocusRef", "interactionName"];
4
4
  import React, { forwardRef, useCallback } from 'react';
5
5
  import mergeRefs from '@atlaskit/ds-lib/merge-refs';
6
6
  import ButtonItem from '@atlaskit/menu/button-item';
7
7
  import CustomItem from '@atlaskit/menu/custom-item';
8
8
  import LinkItem from '@atlaskit/menu/link-item';
9
+ import { fg } from '@atlaskit/platform-feature-flags';
9
10
  import useRegisterItemWithFocusManager from './internal/hooks/use-register-item-with-focus-manager';
10
11
  /**
11
12
  * __Dropdown menu item__
@@ -35,6 +36,7 @@ var DropdownMenuItem = /*#__PURE__*/forwardRef(function (_ref, ref) {
35
36
  testId = _ref.testId,
36
37
  UNSAFE_shouldDisableRouterLink = _ref.UNSAFE_shouldDisableRouterLink,
37
38
  returnFocusRef = _ref.returnFocusRef,
39
+ interactionName = _ref.interactionName,
38
40
  rest = _objectWithoutProperties(_ref, _excluded);
39
41
  var itemRef = useRegisterItemWithFocusManager();
40
42
  var handleItemClick = useCallback(function (event) {
@@ -65,7 +67,8 @@ var DropdownMenuItem = /*#__PURE__*/forwardRef(function (_ref, ref) {
65
67
  ,
66
68
  target: target,
67
69
  rel: rel
68
- // DSP-13312 TODO: remove spread props in future major release
70
+ }, fg('platform_button_item-add-ufo-metrics') && {
71
+ interactionName: interactionName
69
72
  }, rest), children);
70
73
  } else if (href) {
71
74
  return /*#__PURE__*/React.createElement(LinkItem, _extends({
@@ -84,7 +87,8 @@ var DropdownMenuItem = /*#__PURE__*/forwardRef(function (_ref, ref) {
84
87
  target: target,
85
88
  testId: testId,
86
89
  UNSAFE_shouldDisableRouterLink: UNSAFE_shouldDisableRouterLink
87
- // DSP-13312 TODO: remove spread props in future major release
90
+ }, fg('platform_button_item-add-ufo-metrics') && {
91
+ interactionName: interactionName
88
92
  }, rest), children);
89
93
  } else {
90
94
  return /*#__PURE__*/React.createElement(ButtonItem, _extends({
@@ -105,7 +109,8 @@ var DropdownMenuItem = /*#__PURE__*/forwardRef(function (_ref, ref) {
105
109
  ,
106
110
  target: target,
107
111
  rel: rel
108
- // DSP-13312 TODO: remove spread props in future major release
112
+ }, fg('platform_button_item-add-ufo-metrics') && {
113
+ interactionName: interactionName
109
114
  }, rest), children);
110
115
  }
111
116
  });
@@ -14,6 +14,7 @@ import noop from '@atlaskit/ds-lib/noop';
14
14
  import useControlledState from '@atlaskit/ds-lib/use-controlled';
15
15
  import useFocus from '@atlaskit/ds-lib/use-focus-event';
16
16
  import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
17
+ import { fg } from '@atlaskit/platform-feature-flags';
17
18
  import Popup from '@atlaskit/popup';
18
19
  // eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
19
20
  import { gridSize as gridSizeFn, layers } from '@atlaskit/theme/constants';
@@ -88,7 +89,8 @@ var DropdownMenu = function DropdownMenu(_ref) {
88
89
  _trigger = _ref.trigger,
89
90
  _ref$zIndex = _ref.zIndex,
90
91
  zIndex = _ref$zIndex === void 0 ? layers.modal() : _ref$zIndex,
91
- label = _ref.label;
92
+ label = _ref.label,
93
+ interactionName = _ref.interactionName;
92
94
  var _useControlledState = useControlledState(isOpen, function () {
93
95
  return defaultOpen;
94
96
  }),
@@ -137,7 +139,7 @@ var DropdownMenu = function DropdownMenu(_ref) {
137
139
  isOpen: newValue,
138
140
  event: event
139
141
  });
140
- }, [itemRef, onOpenChange, isLocalOpen, setLocalIsOpen]);
142
+ }, [isLocalOpen, setLocalIsOpen, onOpenChange, itemRef]);
141
143
  var handleOnClose = useCallback(function (event, currentLevel) {
142
144
  var _event$target, _event$target$closest;
143
145
  if (event.key !== 'Escape' && event.key !== 'Tab' && (_event$target = event.target) !== null && _event$target !== void 0 && (_event$target$closest = _event$target.closest) !== null && _event$target$closest !== void 0 && _event$target$closest.call(_event$target, "[id^=".concat(PREFIX, "] [aria-haspopup]"))) {
@@ -282,6 +284,8 @@ var DropdownMenu = function DropdownMenu(_ref) {
282
284
  onClick: handleTriggerClicked,
283
285
  testId: testId && "".concat(testId, "--trigger"),
284
286
  "aria-label": label
287
+ }, fg('platform_button_item-add-ufo-metrics') && {
288
+ interactionName: interactionName
285
289
  }), _trigger);
286
290
  },
287
291
  content: function content(_ref3) {
@@ -9,7 +9,7 @@ import handleFocus from '../utils/handle-focus';
9
9
  *
10
10
  * Context provider which maintains the list of focusable elements and a method to
11
11
  * register new menu items.
12
- * This list drives the keyboard navgation of the menu.
12
+ * This list drives the keyboard navigation of the menu.
13
13
  *
14
14
  */
15
15
  export var FocusManagerContext = /*#__PURE__*/createContext({
@@ -24,15 +24,16 @@ var FocusManager = function FocusManager(_ref) {
24
24
  var children = _ref.children,
25
25
  onClose = _ref.onClose;
26
26
  var menuItemRefs = useRef([]);
27
+ var registerRefCalls = useRef(0);
27
28
  var registerRef = useCallback(function (ref) {
28
- if (ref && !menuItemRefs.current.includes(ref)) {
29
- menuItemRefs.current.push(ref);
30
- }
29
+ return upsertRefAtFirstPosition(ref, menuItemRefs, registerRefCalls);
31
30
  }, []);
32
31
  var _UNSAFE_useLayering = UNSAFE_useLayering(),
33
32
  isLayerDisabled = _UNSAFE_useLayering.isLayerDisabled;
34
- // Intentionally rebinding on each render
35
33
  useEffect(function () {
34
+ // Intentionally reset count on each render
35
+ registerRefCalls.current = 0;
36
+ // Intentionally rebinding on each render
36
37
  return bind(window, {
37
38
  type: 'keydown',
38
39
  listener: handleFocus(menuItemRefs.current, isLayerDisabled, onClose)
@@ -46,4 +47,37 @@ var FocusManager = function FocusManager(_ref) {
46
47
  value: contextValue
47
48
  }, children);
48
49
  };
50
+
51
+ /**
52
+ * Insert the ref at the call position in the array.
53
+ * If the ref is already in the array, move it to the call position.
54
+ * If the call position is after the current position, ignore the call.
55
+ *
56
+ * @param ref
57
+ * @param menuItemRefs
58
+ * @param registerRefCalls
59
+ */
60
+ function upsertRefAtFirstPosition(ref, menuItemRefs, registerRefCalls) {
61
+ var positionOnCall = registerRefCalls.current++;
62
+
63
+ // Add the ref to the correct position
64
+ if (!menuItemRefs.current.includes(ref)) {
65
+ menuItemRefs.current.splice(positionOnCall, 0, ref);
66
+ return;
67
+ }
68
+ var positionCurrent = menuItemRefs.current.indexOf(ref);
69
+ if (positionOnCall === positionCurrent) {
70
+ // No change needed
71
+ return;
72
+ }
73
+ if (positionOnCall > positionCurrent) {
74
+ // Ignore and so keep the count the same
75
+ registerRefCalls.current--;
76
+ return;
77
+ }
78
+
79
+ // Update the position of the ref in the array
80
+ menuItemRefs.current.splice(positionCurrent, 1);
81
+ menuItemRefs.current.splice(positionOnCall, 0, ref);
82
+ }
49
83
  export default FocusManager;
@@ -7,7 +7,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
7
7
  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; }
8
8
  import React, { createContext, useContext, useState } from 'react';
9
9
  import noop from '@atlaskit/ds-lib/noop';
10
- import { useId } from '@atlaskit/ds-lib/react-uid';
10
+ import { useId } from '@atlaskit/ds-lib/use-id';
11
11
  import { Section } from '@atlaskit/menu';
12
12
  import GroupTitle from '../internal/components/group-title';
13
13
  import { SelectionStoreContext } from '../internal/context/selection-store';
@@ -1,11 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["children", "defaultSelected", "testId", "id", "title", "description", "isDisabled", "isSelected", "onClick", "shouldDescriptionWrap", "shouldTitleWrap"];
4
+ var _excluded = ["children", "defaultSelected", "testId", "id", "title", "description", "isDisabled", "isSelected", "onClick", "shouldDescriptionWrap", "shouldTitleWrap", "interactionName"];
5
5
  import React, { useCallback } from 'react';
6
6
  import noop from '@atlaskit/ds-lib/noop';
7
7
  import { SELECTION_STYLE_CONTEXT_DO_NOT_USE } from '@atlaskit/menu';
8
8
  import ButtonItem from '@atlaskit/menu/button-item';
9
+ import { fg } from '@atlaskit/platform-feature-flags';
9
10
  import RadioIcon from '../internal/components/radio-icon';
10
11
  import useRadioState from '../internal/hooks/use-radio-state';
11
12
  import useRegisterItemWithFocusManager from '../internal/hooks/use-register-item-with-focus-manager';
@@ -34,6 +35,7 @@ var DropdownItemRadio = function DropdownItemRadio(_ref) {
34
35
  shouldDescriptionWrap = _ref$shouldDescriptio === void 0 ? true : _ref$shouldDescriptio,
35
36
  _ref$shouldTitleWrap = _ref.shouldTitleWrap,
36
37
  shouldTitleWrap = _ref$shouldTitleWrap === void 0 ? true : _ref$shouldTitleWrap,
38
+ interactionName = _ref.interactionName,
37
39
  rest = _objectWithoutProperties(_ref, _excluded);
38
40
  if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production' && typeof isSelected !== 'undefined' && typeof defaultSelected !== 'undefined') {
39
41
  // eslint-disable-next-line no-console
@@ -76,7 +78,8 @@ var DropdownItemRadio = function DropdownItemRadio(_ref) {
76
78
  // @ts-expect-error
77
79
  ,
78
80
  title: title
79
- // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
81
+ }, fg('platform_button_item-add-ufo-metrics') && {
82
+ interactionName: interactionName
80
83
  }, rest), children));
81
84
  };
82
85
  export default DropdownItemRadio;
@@ -9,5 +9,5 @@ import { type DropdownItemCheckboxProps } from '../types';
9
9
  * - [Code](https://atlassian.design/components/dropdown-menu/dropdown-item-checkbox/code)
10
10
  * - [Usage](https://atlassian.design/components/dropdown-menu/dropdown-item-checkbox/usage)
11
11
  */
12
- declare const DropdownItemCheckbox: ({ children, defaultSelected, description, id, isDisabled, isSelected, onClick: providedOnClick, shouldDescriptionWrap, shouldTitleWrap, testId, ...rest }: DropdownItemCheckboxProps) => JSX.Element;
12
+ declare const DropdownItemCheckbox: ({ children, defaultSelected, description, id, isDisabled, isSelected, onClick: providedOnClick, shouldDescriptionWrap, shouldTitleWrap, testId, interactionName, ...rest }: DropdownItemCheckboxProps) => JSX.Element;
13
13
  export default DropdownItemCheckbox;
@@ -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, }: 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, }: DropdownMenuProps<T>) => JSX.Element;
13
13
  export default DropdownMenu;
@@ -5,7 +5,7 @@ import { type FocusableElement } from '../../types';
5
5
  *
6
6
  * Context provider which maintains the list of focusable elements and a method to
7
7
  * register new menu items.
8
- * This list drives the keyboard navgation of the menu.
8
+ * This list drives the keyboard navigation of the menu.
9
9
  *
10
10
  */
11
11
  export declare const FocusManagerContext: React.Context<{
@@ -9,5 +9,5 @@ import { type DropdownItemRadioProps } from '../types';
9
9
  * - [Code](https://atlassian.design/components/dropdown-menu/dropdown-item-radio/code)
10
10
  * - [Usage](https://atlassian.design/components/dropdown-menu/dropdown-item-radio/usage)
11
11
  */
12
- declare const DropdownItemRadio: ({ children, defaultSelected, testId, id, title, description, isDisabled, isSelected, onClick: providedOnClick, shouldDescriptionWrap, shouldTitleWrap, ...rest }: DropdownItemRadioProps) => JSX.Element;
12
+ declare const DropdownItemRadio: ({ children, defaultSelected, testId, id, title, description, isDisabled, isSelected, onClick: providedOnClick, shouldDescriptionWrap, shouldTitleWrap, interactionName, ...rest }: DropdownItemRadioProps) => JSX.Element;
13
13
  export default DropdownItemRadio;
@@ -154,6 +154,10 @@ interface InternalDropdownMenuProps<TriggerElement extends HTMLElement = any> {
154
154
  * If ref is passed, focus returns to that specific ref element after dropdown dismissed.
155
155
  */
156
156
  returnFocusRef?: RefObject<HTMLElement>;
157
+ /**
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
+ */
160
+ interactionName?: string;
157
161
  }
158
162
  type StandardDropdownMenuProps<TriggerElement extends HTMLElement = any> = InternalDropdownMenuProps<TriggerElement> & {
159
163
  shouldFitContainer?: false;
@@ -242,6 +246,10 @@ export interface DropdownItemProps {
242
246
  * If ref is passed, focus returns to that specific ref element after dropdown item clicked.
243
247
  */
244
248
  returnFocusRef?: RefObject<HTMLElement>;
249
+ /**
250
+ * 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).
251
+ */
252
+ interactionName?: string;
245
253
  }
246
254
  export interface DropdownItemCheckboxProps {
247
255
  /**
@@ -291,6 +299,10 @@ export interface DropdownItemCheckboxProps {
291
299
  * serving as a hook for automated tests.
292
300
  */
293
301
  testId?: string;
302
+ /**
303
+ * 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).
304
+ */
305
+ interactionName?: string;
294
306
  }
295
307
  export interface DropdownItemRadioProps {
296
308
  /**
@@ -340,6 +352,10 @@ export interface DropdownItemRadioProps {
340
352
  * serving as a hook for automated tests.
341
353
  */
342
354
  testId?: string;
355
+ /**
356
+ * 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).
357
+ */
358
+ interactionName?: string;
343
359
  }
344
360
  export interface CustomItemHtmlProps extends CustomItemComponentProps {
345
361
  /**
@@ -9,5 +9,5 @@ import { type DropdownItemCheckboxProps } from '../types';
9
9
  * - [Code](https://atlassian.design/components/dropdown-menu/dropdown-item-checkbox/code)
10
10
  * - [Usage](https://atlassian.design/components/dropdown-menu/dropdown-item-checkbox/usage)
11
11
  */
12
- declare const DropdownItemCheckbox: ({ children, defaultSelected, description, id, isDisabled, isSelected, onClick: providedOnClick, shouldDescriptionWrap, shouldTitleWrap, testId, ...rest }: DropdownItemCheckboxProps) => JSX.Element;
12
+ declare const DropdownItemCheckbox: ({ children, defaultSelected, description, id, isDisabled, isSelected, onClick: providedOnClick, shouldDescriptionWrap, shouldTitleWrap, testId, interactionName, ...rest }: DropdownItemCheckboxProps) => JSX.Element;
13
13
  export default DropdownItemCheckbox;
@@ -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, }: 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, }: DropdownMenuProps<T>) => JSX.Element;
13
13
  export default DropdownMenu;
@@ -5,7 +5,7 @@ import { type FocusableElement } from '../../types';
5
5
  *
6
6
  * Context provider which maintains the list of focusable elements and a method to
7
7
  * register new menu items.
8
- * This list drives the keyboard navgation of the menu.
8
+ * This list drives the keyboard navigation of the menu.
9
9
  *
10
10
  */
11
11
  export declare const FocusManagerContext: React.Context<{
@@ -9,5 +9,5 @@ import { type DropdownItemRadioProps } from '../types';
9
9
  * - [Code](https://atlassian.design/components/dropdown-menu/dropdown-item-radio/code)
10
10
  * - [Usage](https://atlassian.design/components/dropdown-menu/dropdown-item-radio/usage)
11
11
  */
12
- declare const DropdownItemRadio: ({ children, defaultSelected, testId, id, title, description, isDisabled, isSelected, onClick: providedOnClick, shouldDescriptionWrap, shouldTitleWrap, ...rest }: DropdownItemRadioProps) => JSX.Element;
12
+ declare const DropdownItemRadio: ({ children, defaultSelected, testId, id, title, description, isDisabled, isSelected, onClick: providedOnClick, shouldDescriptionWrap, shouldTitleWrap, interactionName, ...rest }: DropdownItemRadioProps) => JSX.Element;
13
13
  export default DropdownItemRadio;
@@ -154,6 +154,10 @@ interface InternalDropdownMenuProps<TriggerElement extends HTMLElement = any> {
154
154
  * If ref is passed, focus returns to that specific ref element after dropdown dismissed.
155
155
  */
156
156
  returnFocusRef?: RefObject<HTMLElement>;
157
+ /**
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
+ */
160
+ interactionName?: string;
157
161
  }
158
162
  type StandardDropdownMenuProps<TriggerElement extends HTMLElement = any> = InternalDropdownMenuProps<TriggerElement> & {
159
163
  shouldFitContainer?: false;
@@ -242,6 +246,10 @@ export interface DropdownItemProps {
242
246
  * If ref is passed, focus returns to that specific ref element after dropdown item clicked.
243
247
  */
244
248
  returnFocusRef?: RefObject<HTMLElement>;
249
+ /**
250
+ * 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).
251
+ */
252
+ interactionName?: string;
245
253
  }
246
254
  export interface DropdownItemCheckboxProps {
247
255
  /**
@@ -291,6 +299,10 @@ export interface DropdownItemCheckboxProps {
291
299
  * serving as a hook for automated tests.
292
300
  */
293
301
  testId?: string;
302
+ /**
303
+ * 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).
304
+ */
305
+ interactionName?: string;
294
306
  }
295
307
  export interface DropdownItemRadioProps {
296
308
  /**
@@ -340,6 +352,10 @@ export interface DropdownItemRadioProps {
340
352
  * serving as a hook for automated tests.
341
353
  */
342
354
  testId?: string;
355
+ /**
356
+ * 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).
357
+ */
358
+ interactionName?: string;
343
359
  }
344
360
  export interface CustomItemHtmlProps extends CustomItemComponentProps {
345
361
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/dropdown-menu",
3
- "version": "12.18.4",
3
+ "version": "12.18.6",
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,7 +25,7 @@
25
25
  "dependencies": {
26
26
  "@atlaskit/button": "^20.2.0",
27
27
  "@atlaskit/codemod-utils": "^4.2.0",
28
- "@atlaskit/ds-lib": "^2.6.0",
28
+ "@atlaskit/ds-lib": "^2.7.0",
29
29
  "@atlaskit/icon": "^22.20.0",
30
30
  "@atlaskit/layering": "^0.5.0",
31
31
  "@atlaskit/menu": "^2.12.0",
@@ -72,6 +72,9 @@
72
72
  "platform-feature-flags": {
73
73
  "platform_dst_popup-disable-focuslock": {
74
74
  "type": "boolean"
75
+ },
76
+ "platform_button_item-add-ufo-metrics": {
77
+ "type": "boolean"
75
78
  }
76
79
  },
77
80
  "techstack": {