@atlaskit/select 20.0.8 → 20.2.0

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,37 @@
1
1
  # @atlaskit/select
2
2
 
3
+ ## 20.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#138461](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/138461)
8
+ [`455c7f648d71a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/455c7f648d71a) -
9
+ Internal refactor to PopupSelect behind a feature flag.
10
+
11
+ - No longer closing the popup when the internal select menu's onMenuClose is called.
12
+ - It now registers with the experimental open layer observer, allowing it to close when the
13
+ observer gives the close signal (e.g. when resizing a page layout slot).
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies
18
+
19
+ ## 20.1.0
20
+
21
+ ### Minor Changes
22
+
23
+ - [#135853](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/135853)
24
+ [`63233b4c0a6a7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/63233b4c0a6a7) -
25
+ PopupSelect will now close when the internal select menu's onMenuClose is called.
26
+
27
+ This is used to close any open select menus when page layout slots are resized.
28
+
29
+ This change is behind a feature flag.
30
+
31
+ ### Patch Changes
32
+
33
+ - Updated dependencies
34
+
3
35
  ## 20.0.8
4
36
 
5
37
  ### Patch Changes
@@ -28,6 +28,7 @@ var _colors = require("@atlaskit/theme/colors");
28
28
  var _Select = _interopRequireDefault(require("../Select"));
29
29
  var _groupedOptionsAnnouncement = require("../utils/grouped-options-announcement");
30
30
  var _components = require("./components");
31
+ var _notifyOpenLayerObserver = require("./notify-open-layer-observer");
31
32
  var _excluded = ["footer", "label", "maxMenuWidth", "minMenuWidth", "placeholder", "target", "testId", "onMenuOpen", "onMenuClose"];
32
33
  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); }
33
34
  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; }
@@ -452,10 +453,19 @@ var PopupSelect = exports.default = /*#__PURE__*/function (_PureComponent) {
452
453
  // Overwriting ariaLiveMessages builtin onFocus method to announce selected option when popup has been opened
453
454
  onFocus: onReactSelectFocus
454
455
  }, props.ariaLiveMessages)
456
+ // Note: We are intentionally not using `onMenuClose={this.close}` here, due to state management conflicts
457
+ // between PopupSelect's popup and the internal select menu. This can result in the PopupSelect closing
458
+ // or opening unexpectedly.
455
459
  })), footer));
456
460
  });
457
461
  return mergedPopperProps.strategy === 'fixed' ? popper : /*#__PURE__*/(0, _reactDom.createPortal)(popper, portalDestination);
458
462
  });
463
+ (0, _defineProperty2.default)(_this, "handleOpenLayerObserverCloseSignal", function () {
464
+ if (!(0, _platformFeatureFlags.fg)('platform_dst_layer_observer_select')) {
465
+ return;
466
+ }
467
+ _this.close();
468
+ });
459
469
  return _this;
460
470
  }
461
471
  (0, _inherits2.default)(PopupSelect, _PureComponent);
@@ -522,6 +532,9 @@ var PopupSelect = exports.default = /*#__PURE__*/function (_PureComponent) {
522
532
  'aria-controls': isOpen ? id : undefined
523
533
  });
524
534
  }), _this3.renderSelect(id));
535
+ }), /*#__PURE__*/_react.default.createElement(_notifyOpenLayerObserver.NotifyOpenLayerObserver, {
536
+ isOpen: (0, _platformFeatureFlags.fg)('platform_dst_layer_observer_select') && this.state.isOpen,
537
+ onClose: this.handleOpenLayerObserverCloseSignal
525
538
  }));
526
539
  }
527
540
  }], [{
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NotifyOpenLayerObserver = NotifyOpenLayerObserver;
7
+ var _openLayerObserver = require("@atlaskit/layering/experimental/open-layer-observer");
8
+ /**
9
+ * Functional component wrapper around `useNotifyOpenLayerObserver`.
10
+ *
11
+ * This is needed as PopupSelect is a class component, which cannot use hooks directly.
12
+ *
13
+ * Even though the internal `Select` component (used internally by `PopupSelect`) also registers with
14
+ * the OpenLayerObserver, we are also registering `PopupSelect` as well, to allow the observer to close
15
+ * the `PopupSelect`'s outer popup.
16
+ *
17
+ * This will technically count as 2 open layers, however the specific count is not important - the main
18
+ * concern is that the observer can know if there are _any_ open layers (0, or 1+), and how to close them.
19
+ */
20
+ function NotifyOpenLayerObserver(_ref) {
21
+ var isOpen = _ref.isOpen,
22
+ onClose = _ref.onClose;
23
+ (0, _openLayerObserver.useNotifyOpenLayerObserver)({
24
+ isOpen: isOpen,
25
+ onClose: onClose
26
+ });
27
+ return null;
28
+ }
@@ -11,7 +11,7 @@ var _createSelect = _interopRequireDefault(require("./createSelect"));
11
11
  /* eslint-disable @repo/internal/react/require-jsdoc */
12
12
 
13
13
  var packageName = "@atlaskit/select";
14
- var packageVersion = "20.0.8";
14
+ var packageVersion = "20.2.0";
15
15
  var SelectWithoutAnalytics = exports.SelectWithoutAnalytics = (0, _createSelect.default)(_async.default);
16
16
  var createAndFireEventOnAtlaskit = (0, _analyticsNext.createAndFireEvent)('atlaskit');
17
17
  var Select = (0, _analyticsNext.withAnalyticsContext)({
@@ -16,6 +16,7 @@ import { N80 } from '@atlaskit/theme/colors';
16
16
  import Select from '../Select';
17
17
  import { countAllOptions, isOptionsGrouped, onFocus } from '../utils/grouped-options-announcement';
18
18
  import { defaultComponents, DummyControl, MenuDialog } from './components';
19
+ import { NotifyOpenLayerObserver } from './notify-open-layer-observer';
19
20
  /**
20
21
  * Are we rendering on the client or server?
21
22
  */
@@ -436,9 +437,18 @@ export default class PopupSelect extends PureComponent {
436
437
  onFocus: onReactSelectFocus,
437
438
  ...props.ariaLiveMessages // priority to use user handlers if provided
438
439
  }
440
+ // Note: We are intentionally not using `onMenuClose={this.close}` here, due to state management conflicts
441
+ // between PopupSelect's popup and the internal select menu. This can result in the PopupSelect closing
442
+ // or opening unexpectedly.
439
443
  })), footer)));
440
444
  return mergedPopperProps.strategy === 'fixed' ? popper : /*#__PURE__*/createPortal(popper, portalDestination);
441
445
  });
446
+ _defineProperty(this, "handleOpenLayerObserverCloseSignal", () => {
447
+ if (!fg('platform_dst_layer_observer_select')) {
448
+ return;
449
+ }
450
+ this.close();
451
+ });
442
452
  }
443
453
  static getDerivedStateFromProps(props, state) {
444
454
  const newState = {};
@@ -523,7 +533,10 @@ export default class PopupSelect extends PureComponent {
523
533
  'aria-haspopup': 'true',
524
534
  'aria-expanded': isOpen,
525
535
  'aria-controls': isOpen ? id : undefined
526
- })), this.renderSelect(id))));
536
+ })), this.renderSelect(id))), /*#__PURE__*/React.createElement(NotifyOpenLayerObserver, {
537
+ isOpen: fg('platform_dst_layer_observer_select') && this.state.isOpen,
538
+ onClose: this.handleOpenLayerObserverCloseSignal
539
+ }));
527
540
  }
528
541
  }
529
542
  _defineProperty(PopupSelect, "defaultProps", {
@@ -0,0 +1,23 @@
1
+ import { useNotifyOpenLayerObserver } from '@atlaskit/layering/experimental/open-layer-observer';
2
+ /**
3
+ * Functional component wrapper around `useNotifyOpenLayerObserver`.
4
+ *
5
+ * This is needed as PopupSelect is a class component, which cannot use hooks directly.
6
+ *
7
+ * Even though the internal `Select` component (used internally by `PopupSelect`) also registers with
8
+ * the OpenLayerObserver, we are also registering `PopupSelect` as well, to allow the observer to close
9
+ * the `PopupSelect`'s outer popup.
10
+ *
11
+ * This will technically count as 2 open layers, however the specific count is not important - the main
12
+ * concern is that the observer can know if there are _any_ open layers (0, or 1+), and how to close them.
13
+ */
14
+ export function NotifyOpenLayerObserver({
15
+ isOpen,
16
+ onClose
17
+ }) {
18
+ useNotifyOpenLayerObserver({
19
+ isOpen,
20
+ onClose
21
+ });
22
+ return null;
23
+ }
@@ -3,7 +3,7 @@ import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@
3
3
  import AsyncSelect from '@atlaskit/react-select/async';
4
4
  import createSelect from './createSelect';
5
5
  const packageName = "@atlaskit/select";
6
- const packageVersion = "20.0.8";
6
+ const packageVersion = "20.2.0";
7
7
  export const SelectWithoutAnalytics = createSelect(AsyncSelect);
8
8
  const createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
9
9
  const Select = withAnalyticsContext({
@@ -27,6 +27,7 @@ import { N80 } from '@atlaskit/theme/colors';
27
27
  import Select from '../Select';
28
28
  import { countAllOptions, isOptionsGrouped, onFocus } from '../utils/grouped-options-announcement';
29
29
  import { defaultComponents, DummyControl, MenuDialog } from './components';
30
+ import { NotifyOpenLayerObserver } from './notify-open-layer-observer';
30
31
  /**
31
32
  * Are we rendering on the client or server?
32
33
  */
@@ -444,10 +445,19 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
444
445
  // Overwriting ariaLiveMessages builtin onFocus method to announce selected option when popup has been opened
445
446
  onFocus: onReactSelectFocus
446
447
  }, props.ariaLiveMessages)
448
+ // Note: We are intentionally not using `onMenuClose={this.close}` here, due to state management conflicts
449
+ // between PopupSelect's popup and the internal select menu. This can result in the PopupSelect closing
450
+ // or opening unexpectedly.
447
451
  })), footer));
448
452
  });
449
453
  return mergedPopperProps.strategy === 'fixed' ? popper : /*#__PURE__*/createPortal(popper, portalDestination);
450
454
  });
455
+ _defineProperty(_this, "handleOpenLayerObserverCloseSignal", function () {
456
+ if (!fg('platform_dst_layer_observer_select')) {
457
+ return;
458
+ }
459
+ _this.close();
460
+ });
451
461
  return _this;
452
462
  }
453
463
  _inherits(PopupSelect, _PureComponent);
@@ -514,6 +524,9 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
514
524
  'aria-controls': isOpen ? id : undefined
515
525
  });
516
526
  }), _this3.renderSelect(id));
527
+ }), /*#__PURE__*/React.createElement(NotifyOpenLayerObserver, {
528
+ isOpen: fg('platform_dst_layer_observer_select') && this.state.isOpen,
529
+ onClose: this.handleOpenLayerObserverCloseSignal
517
530
  }));
518
531
  }
519
532
  }], [{
@@ -0,0 +1,22 @@
1
+ import { useNotifyOpenLayerObserver } from '@atlaskit/layering/experimental/open-layer-observer';
2
+ /**
3
+ * Functional component wrapper around `useNotifyOpenLayerObserver`.
4
+ *
5
+ * This is needed as PopupSelect is a class component, which cannot use hooks directly.
6
+ *
7
+ * Even though the internal `Select` component (used internally by `PopupSelect`) also registers with
8
+ * the OpenLayerObserver, we are also registering `PopupSelect` as well, to allow the observer to close
9
+ * the `PopupSelect`'s outer popup.
10
+ *
11
+ * This will technically count as 2 open layers, however the specific count is not important - the main
12
+ * concern is that the observer can know if there are _any_ open layers (0, or 1+), and how to close them.
13
+ */
14
+ export function NotifyOpenLayerObserver(_ref) {
15
+ var isOpen = _ref.isOpen,
16
+ onClose = _ref.onClose;
17
+ useNotifyOpenLayerObserver({
18
+ isOpen: isOpen,
19
+ onClose: onClose
20
+ });
21
+ return null;
22
+ }
@@ -3,7 +3,7 @@ import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@
3
3
  import AsyncSelect from '@atlaskit/react-select/async';
4
4
  import createSelect from './createSelect';
5
5
  var packageName = "@atlaskit/select";
6
- var packageVersion = "20.0.8";
6
+ var packageVersion = "20.2.0";
7
7
  export var SelectWithoutAnalytics = createSelect(AsyncSelect);
8
8
  var createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
9
9
  var Select = withAnalyticsContext({
@@ -164,6 +164,7 @@ export default class PopupSelect<Option = OptionType, IsMulti extends boolean =
164
164
  getMaxHeight: () => number | undefined;
165
165
  showSearchControl: () => boolean | undefined;
166
166
  renderSelect: (id: string) => React.JSX.Element | null;
167
+ handleOpenLayerObserverCloseSignal: () => void;
167
168
  render(): React.JSX.Element;
168
169
  }
169
170
  export {};
@@ -0,0 +1,18 @@
1
+ type NotifyOpenLayerObserverProps = {
2
+ isOpen: boolean;
3
+ onClose: () => void;
4
+ };
5
+ /**
6
+ * Functional component wrapper around `useNotifyOpenLayerObserver`.
7
+ *
8
+ * This is needed as PopupSelect is a class component, which cannot use hooks directly.
9
+ *
10
+ * Even though the internal `Select` component (used internally by `PopupSelect`) also registers with
11
+ * the OpenLayerObserver, we are also registering `PopupSelect` as well, to allow the observer to close
12
+ * the `PopupSelect`'s outer popup.
13
+ *
14
+ * This will technically count as 2 open layers, however the specific count is not important - the main
15
+ * concern is that the observer can know if there are _any_ open layers (0, or 1+), and how to close them.
16
+ */
17
+ export declare function NotifyOpenLayerObserver({ isOpen, onClose }: NotifyOpenLayerObserverProps): null;
18
+ export {};
@@ -164,6 +164,7 @@ export default class PopupSelect<Option = OptionType, IsMulti extends boolean =
164
164
  getMaxHeight: () => number | undefined;
165
165
  showSearchControl: () => boolean | undefined;
166
166
  renderSelect: (id: string) => React.JSX.Element | null;
167
+ handleOpenLayerObserverCloseSignal: () => void;
167
168
  render(): React.JSX.Element;
168
169
  }
169
170
  export {};
@@ -0,0 +1,18 @@
1
+ type NotifyOpenLayerObserverProps = {
2
+ isOpen: boolean;
3
+ onClose: () => void;
4
+ };
5
+ /**
6
+ * Functional component wrapper around `useNotifyOpenLayerObserver`.
7
+ *
8
+ * This is needed as PopupSelect is a class component, which cannot use hooks directly.
9
+ *
10
+ * Even though the internal `Select` component (used internally by `PopupSelect`) also registers with
11
+ * the OpenLayerObserver, we are also registering `PopupSelect` as well, to allow the observer to close
12
+ * the `PopupSelect`'s outer popup.
13
+ *
14
+ * This will technically count as 2 open layers, however the specific count is not important - the main
15
+ * concern is that the observer can know if there are _any_ open layers (0, or 1+), and how to close them.
16
+ */
17
+ export declare function NotifyOpenLayerObserver({ isOpen, onClose }: NotifyOpenLayerObserverProps): null;
18
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/select",
3
- "version": "20.0.8",
3
+ "version": "20.2.0",
4
4
  "description": "Select allows users to make a single selection or multiple selections from a list of options.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -43,13 +43,13 @@
43
43
  "dependencies": {
44
44
  "@atlaskit/analytics-next": "^11.0.0",
45
45
  "@atlaskit/ds-lib": "^4.0.0",
46
- "@atlaskit/icon": "^25.1.0",
46
+ "@atlaskit/icon": "^25.5.0",
47
47
  "@atlaskit/platform-feature-flags": "^1.1.0",
48
- "@atlaskit/primitives": "^14.2.0",
49
- "@atlaskit/react-select": "^2.0.0",
48
+ "@atlaskit/primitives": "^14.3.0",
49
+ "@atlaskit/react-select": "^2.1.0",
50
50
  "@atlaskit/spinner": "^18.0.0",
51
51
  "@atlaskit/theme": "^18.0.0",
52
- "@atlaskit/tokens": "^4.5.0",
52
+ "@atlaskit/tokens": "^4.7.0",
53
53
  "@atlaskit/visually-hidden": "^3.0.0",
54
54
  "@babel/runtime": "^7.0.0",
55
55
  "@compiled/react": "^0.18.3",
@@ -67,17 +67,17 @@
67
67
  "@af/accessibility-testing": "^2.0.0",
68
68
  "@af/integration-testing": "^0.5.0",
69
69
  "@af/visual-regression": "^1.3.0",
70
- "@atlaskit/button": "^21.1.0",
70
+ "@atlaskit/button": "^23.0.0",
71
71
  "@atlaskit/checkbox": "^17.0.0",
72
72
  "@atlaskit/docs": "^10.0.0",
73
- "@atlaskit/drawer": "^10.0.0",
73
+ "@atlaskit/drawer": "^10.1.0",
74
74
  "@atlaskit/form": "^12.0.0",
75
- "@atlaskit/link": "^3.0.0",
75
+ "@atlaskit/link": "^3.1.0",
76
76
  "@atlaskit/logo": "^16.0.0",
77
- "@atlaskit/modal-dialog": "^14.0.0",
77
+ "@atlaskit/modal-dialog": "^14.1.0",
78
78
  "@atlaskit/radio": "^8.0.0",
79
79
  "@atlaskit/section-message": "^8.2.0",
80
- "@atlaskit/ssr": "^0.4.0",
80
+ "@atlassian/ssr-tests": "^0.2.0",
81
81
  "@testing-library/react": "^13.4.0",
82
82
  "@testing-library/user-event": "^14.4.3",
83
83
  "ast-types": "^0.13.3",
@@ -120,6 +120,9 @@
120
120
  },
121
121
  "platform_design_system_team_safari_input_fix": {
122
122
  "type": "boolean"
123
+ },
124
+ "platform_dst_layer_observer_select": {
125
+ "type": "boolean"
123
126
  }
124
127
  },
125
128
  "homepage": "https://atlassian.design/components/select/"