@atlaskit/dropdown-menu 16.0.7 → 16.1.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,20 @@
1
1
  # @atlaskit/dropdown-menu
2
2
 
3
+ ## 16.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 16.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#161732](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/161732)
14
+ [`a3b57a07e1158`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a3b57a07e1158) -
15
+ Fixes persistence of radio item `defaultSelected` state. This change is behind the
16
+ `platform_dst_dropdown_radio_default_selected_fix` feature gate.
17
+
3
18
  ## 16.0.7
4
19
 
5
20
  ### Patch Changes
@@ -8,6 +8,7 @@ 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");
11
12
  var _dropdownItemRadioGroup = require("../../radio/dropdown-item-radio-group");
12
13
  var _selectionStore = require("../context/selection-store");
13
14
  var _resetOptionsInGroup = _interopRequireDefault(require("../utils/reset-options-in-group"));
@@ -55,9 +56,17 @@ function useRadioState(_ref) {
55
56
  return false;
56
57
  }];
57
58
  }
59
+
60
+ /**
61
+ * Set the initial state of the context provider's store,
62
+ * if it doesn't already have a persisted value for this id.
63
+ */
58
64
  if (persistedIsSelected === undefined) {
59
65
  var existing = getGroupState(group);
60
- setGroupState(group, _objectSpread(_objectSpread({}, (0, _resetOptionsInGroup.default)(existing || {})), {}, (0, _defineProperty2.default)({}, id, defaultSelected || false)));
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));
69
+ setGroupState(group, newGroupState);
61
70
  }
62
71
  return [localIsSelected, setLocalState];
63
72
  }
@@ -1,4 +1,5 @@
1
1
  import { useCallback, useContext, useEffect, useState } from 'react';
2
+ import { fg } from '@atlaskit/platform-feature-flags';
2
3
  import { RadioGroupContext } from '../../radio/dropdown-item-radio-group';
3
4
  import { SelectionStoreContext } from '../context/selection-store';
4
5
  import resetOptionsInGroup from '../utils/reset-options-in-group';
@@ -40,12 +41,25 @@ function useRadioState({
40
41
  if (typeof isSelected === 'boolean') {
41
42
  return [isSelected, () => false];
42
43
  }
44
+
45
+ /**
46
+ * Set the initial state of the context provider's store,
47
+ * if it doesn't already have a persisted value for this id.
48
+ */
43
49
  if (persistedIsSelected === undefined) {
44
50
  const existing = getGroupState(group);
45
- setGroupState(group, {
51
+ const newGroupState = fg('platform_dst_dropdown_radio_default_selected_fix') ?
52
+ // FF on: only the current is changed
53
+ {
54
+ ...existing,
55
+ [id]: defaultSelected || false
56
+ } :
57
+ // FF off: everything else also gets set to false
58
+ {
46
59
  ...resetOptionsInGroup(existing || {}),
47
60
  [id]: defaultSelected || false
48
- });
61
+ };
62
+ setGroupState(group, newGroupState);
49
63
  }
50
64
  return [localIsSelected, setLocalState];
51
65
  }
@@ -3,6 +3,7 @@ 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';
6
7
  import { RadioGroupContext } from '../../radio/dropdown-item-radio-group';
7
8
  import { SelectionStoreContext } from '../context/selection-store';
8
9
  import resetOptionsInGroup from '../utils/reset-options-in-group';
@@ -48,9 +49,17 @@ function useRadioState(_ref) {
48
49
  return false;
49
50
  }];
50
51
  }
52
+
53
+ /**
54
+ * Set the initial state of the context provider's store,
55
+ * if it doesn't already have a persisted value for this id.
56
+ */
51
57
  if (persistedIsSelected === undefined) {
52
58
  var existing = getGroupState(group);
53
- setGroupState(group, _objectSpread(_objectSpread({}, resetOptionsInGroup(existing || {})), {}, _defineProperty({}, id, defaultSelected || false)));
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));
62
+ setGroupState(group, newGroupState);
54
63
  }
55
64
  return [localIsSelected, setLocalState];
56
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/dropdown-menu",
3
- "version": "16.0.7",
3
+ "version": "16.1.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,17 +26,17 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@atlaskit/button": "^23.2.0",
29
- "@atlaskit/css": "^0.10.0",
29
+ "@atlaskit/css": "^0.11.0",
30
30
  "@atlaskit/ds-lib": "^4.0.0",
31
31
  "@atlaskit/icon": "^27.0.0",
32
32
  "@atlaskit/layering": "^3.0.0",
33
33
  "@atlaskit/menu": "^8.0.0",
34
34
  "@atlaskit/platform-feature-flags": "^1.1.0",
35
35
  "@atlaskit/popup": "^4.3.0",
36
- "@atlaskit/primitives": "^14.8.0",
36
+ "@atlaskit/primitives": "^14.9.0",
37
37
  "@atlaskit/spinner": "^18.0.0",
38
38
  "@atlaskit/theme": "^18.0.0",
39
- "@atlaskit/tokens": "^5.2.0",
39
+ "@atlaskit/tokens": "^5.3.0",
40
40
  "@babel/runtime": "^7.0.0",
41
41
  "bind-event-listener": "^3.0.0"
42
42
  },
@@ -61,8 +61,10 @@
61
61
  "@atlaskit/section-message": "^8.2.0",
62
62
  "@atlaskit/textfield": "^8.0.0",
63
63
  "@atlaskit/toggle": "^15.0.0",
64
+ "@atlassian/feature-flags-test-utils": "^0.3.0",
64
65
  "@testing-library/react": "^13.4.0",
65
66
  "@testing-library/react-hooks": "^8.0.1",
67
+ "@testing-library/user-event": "^14.4.3",
66
68
  "jest-in-case": "^1.0.2",
67
69
  "raf-stub": "^2.0.1",
68
70
  "react-dom": "^18.2.0",
@@ -89,6 +91,9 @@
89
91
  },
90
92
  "platform_design_system_team_dropdown_return_focus": {
91
93
  "type": "boolean"
94
+ },
95
+ "platform_dst_dropdown_radio_default_selected_fix": {
96
+ "type": "boolean"
92
97
  }
93
98
  },
94
99
  "techstack": {