@atlaskit/react-select 2.0.6 → 2.1.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,26 @@
1
1
  # @atlaskit/react-select
2
2
 
3
+ ## 2.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#135853](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/135853)
8
+ [`37d9e41733fc5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/37d9e41733fc5) -
9
+ Select components now sync with the experimental open layer observer, using the
10
+ useNotifyOpenLayerObserver hook.
11
+
12
+ This is used to close any open select menus when page layout slots are resized.
13
+
14
+ These changes are behind feature flags.
15
+
16
+ ## 2.0.7
17
+
18
+ ### Patch Changes
19
+
20
+ - [#131835](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/131835)
21
+ [`11b3a9f6a407e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/11b3a9f6a407e) -
22
+ [Popup Select] Improve assistive technology support by reducing reliance on live regions.
23
+
3
24
  ## 2.0.6
4
25
 
5
26
  ### Patch Changes
@@ -0,0 +1,21 @@
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 Select is a class component, which cannot use hooks directly.
12
+ */
13
+ function NotifyOpenLayerObserver(_ref) {
14
+ var isOpen = _ref.isOpen,
15
+ onClose = _ref.onClose;
16
+ (0, _openLayerObserver.useNotifyOpenLayerObserver)({
17
+ isOpen: isOpen,
18
+ onClose: onClose
19
+ });
20
+ return null;
21
+ }
@@ -127,17 +127,13 @@ var LiveRegion = function LiveRegion(props) {
127
127
  var ariaResults = (0, _react.useMemo)(function () {
128
128
  var resultsMsg = '';
129
129
  if (menuIsOpen && options.length && !isLoading && messages.onFilter) {
130
- var shouldAnnounceAvailableResults = !focusableOptions.length;
131
- if (shouldAnnounceAvailableResults && (0, _platformFeatureFlags.fg)('design_system_select-a11y-improvement') || !(0, _platformFeatureFlags.fg)('design_system_select-a11y-improvement')) {
132
- // only announce no option results when ff is on
133
- var resultsMessage = screenReaderStatus({
134
- count: focusableOptions.length
135
- });
136
- resultsMsg = messages.onFilter({
137
- inputValue: inputValue,
138
- resultsMessage: resultsMessage
139
- });
140
- }
130
+ var resultsMessage = screenReaderStatus({
131
+ count: focusableOptions.length
132
+ });
133
+ resultsMsg = messages.onFilter({
134
+ inputValue: inputValue,
135
+ resultsMessage: resultsMessage
136
+ });
141
137
  }
142
138
  return resultsMsg;
143
139
  }, [focusableOptions, inputValue, menuIsOpen, messages, options, screenReaderStatus, isLoading]);
@@ -164,9 +160,9 @@ var LiveRegion = function LiveRegion(props) {
164
160
  }, [ariaLabel, focusedOption, focusedValue, isMulti, isOptionDisabled, isSearchable, menuIsOpen, messages, selectValue, tabSelectsValue, isInitialFocus]);
165
161
  var ScreenReaderText = (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)("span", {
166
162
  id: "aria-selection"
167
- }, ariaSelected), !(0, _platformFeatureFlags.fg)('design_system_select-a11y-improvement') && (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)("span", {
163
+ }, ariaSelected), (0, _react2.jsx)("span", {
168
164
  id: "aria-results"
169
- }, ariaResults), (0, _react2.jsx)("span", {
165
+ }, ariaResults), !(0, _platformFeatureFlags.fg)('design_system_select-a11y-improvement') && (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)("span", {
170
166
  id: "aria-focused"
171
167
  }, ariaFocused), (0, _react2.jsx)("span", {
172
168
  id: "aria-guidance"
@@ -21,6 +21,7 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
21
21
  var _builtins = require("./builtins");
22
22
  var _components = require("./components");
23
23
  var _internal = require("./components/internal");
24
+ var _notifyOpenLayerObserver = require("./components/internal/notify-open-layer-observer");
24
25
  var _liveRegion = _interopRequireDefault(require("./components/live-region"));
25
26
  var _menu = require("./components/menu");
26
27
  var _filters = require("./filters");
@@ -826,10 +827,16 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
826
827
  }
827
828
  event.preventDefault();
828
829
  });
830
+ (0, _defineProperty2.default)(_this, "handleOpenLayerObserverCloseSignal", function () {
831
+ if (!(0, _platformFeatureFlags.fg)('platform_dst_layer_observer_select')) {
832
+ return;
833
+ }
834
+ _this.onMenuClose();
835
+ });
829
836
  _this.state.instancePrefix = 'react-select-' + (_this.props.instanceId || ++instanceId);
830
837
  _this.state.selectValue = (0, _utils.cleanValue)(_props.value);
831
838
  // Set focusedOption if menuIsOpen is set on init (e.g. defaultMenuIsOpen)
832
- if (_props.menuIsOpen && _this.state.selectValue.length) {
839
+ if (_props.menuIsOpen) {
833
840
  var focusableOptionsWithIds = _this.getFocusableOptionsWithIds();
834
841
  var focusableOptions = _this.buildFocusableOptions();
835
842
  var optionIndex = focusableOptions.indexOf(_this.state.selectValue[0]);
@@ -1614,6 +1621,26 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1614
1621
  menuPosition: menuPosition,
1615
1622
  menuShouldScrollIntoView: menuShouldScrollIntoView
1616
1623
  };
1624
+ var calculateListboxLabel = function calculateListboxLabel() {
1625
+ var _this4$inputRef;
1626
+ // First in name calculation, overwrites aria-label
1627
+ if (labelId) {
1628
+ return {
1629
+ 'aria-labelledby': labelId
1630
+ };
1631
+ }
1632
+ // Second in name calcuation, overwrites everything else except aria-labelledby
1633
+ if (label) {
1634
+ return {
1635
+ 'aria-label': label
1636
+ };
1637
+ }
1638
+ // Fallback if no label or labelId is provided, might catch label via <label for> otherwise
1639
+ // will most likely not have an accessible name
1640
+ return {
1641
+ 'aria-labelledby': ((_this4$inputRef = _this4.inputRef) === null || _this4$inputRef === void 0 ? void 0 : _this4$inputRef.id) || _this4.getElementId('input')
1642
+ };
1643
+ };
1617
1644
  var menuElement = /*#__PURE__*/_react.default.createElement(_menu.MenuPlacer, (0, _extends2.default)({}, commonProps, menuPlacementProps), function (_ref4) {
1618
1645
  var ref = _ref4.ref,
1619
1646
  _ref4$placerProps = _ref4.placerProps,
@@ -1636,7 +1663,6 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1636
1663
  onBottomArrive: onMenuScrollToBottom,
1637
1664
  lockEnabled: menuShouldBlockScroll
1638
1665
  }, function (scrollTargetRef) {
1639
- var _this4$inputRef;
1640
1666
  return /*#__PURE__*/_react.default.createElement(MenuList, (0, _extends2.default)({}, commonProps, {
1641
1667
  innerRef: function innerRef(instance) {
1642
1668
  _this4.getMenuListRef(instance);
@@ -1648,10 +1674,7 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1648
1674
  id: _this4.getElementId('listbox')
1649
1675
  }, testId && {
1650
1676
  'data-testid': "".concat(testId, "-select--listbox")
1651
- }), (0, _platformFeatureFlags.fg)('design_system_select-a11y-improvement') && {
1652
- 'aria-label': label,
1653
- 'aria-labelledby': "".concat(labelId || ((_this4$inputRef = _this4.inputRef) === null || _this4$inputRef === void 0 ? void 0 : _this4$inputRef.id) || _this4.getElementId('input'))
1654
- }),
1677
+ }), (0, _platformFeatureFlags.fg)('design_system_select-a11y-improvement') && calculateListboxLabel()),
1655
1678
  isLoading: isLoading,
1656
1679
  maxHeight: maxHeight,
1657
1680
  focusedOption: focusedOption
@@ -1815,7 +1838,10 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1815
1838
  innerProps: _objectSpread({}, testId && {
1816
1839
  'data-testid': "".concat(testId, "-select--indicators-container")
1817
1840
  })
1818
- }), this.renderClearIndicator(), this.renderLoadingIndicator(), this.renderDropdownIndicator())), this.renderMenu(), this.renderFormField());
1841
+ }), this.renderClearIndicator(), this.renderLoadingIndicator(), this.renderDropdownIndicator())), this.renderMenu(), this.renderFormField(), /*#__PURE__*/_react.default.createElement(_notifyOpenLayerObserver.NotifyOpenLayerObserver, {
1842
+ isOpen: (0, _platformFeatureFlags.fg)('platform_dst_layer_observer_select') && this.props.menuIsOpen,
1843
+ onClose: this.handleOpenLayerObserverCloseSignal
1844
+ }));
1819
1845
  }
1820
1846
  }], [{
1821
1847
  key: "getDerivedStateFromProps",
@@ -0,0 +1,16 @@
1
+ import { useNotifyOpenLayerObserver } from '@atlaskit/layering/experimental/open-layer-observer';
2
+ /**
3
+ * Functional component wrapper around `useNotifyOpenLayerObserver`.
4
+ *
5
+ * This is needed as Select is a class component, which cannot use hooks directly.
6
+ */
7
+ export function NotifyOpenLayerObserver({
8
+ isOpen,
9
+ onClose
10
+ }) {
11
+ useNotifyOpenLayerObserver({
12
+ isOpen,
13
+ onClose
14
+ });
15
+ return null;
16
+ }
@@ -123,17 +123,13 @@ const LiveRegion = props => {
123
123
  const ariaResults = useMemo(() => {
124
124
  let resultsMsg = '';
125
125
  if (menuIsOpen && options.length && !isLoading && messages.onFilter) {
126
- const shouldAnnounceAvailableResults = !focusableOptions.length;
127
- if (shouldAnnounceAvailableResults && fg('design_system_select-a11y-improvement') || !fg('design_system_select-a11y-improvement')) {
128
- // only announce no option results when ff is on
129
- const resultsMessage = screenReaderStatus({
130
- count: focusableOptions.length
131
- });
132
- resultsMsg = messages.onFilter({
133
- inputValue,
134
- resultsMessage
135
- });
136
- }
126
+ const resultsMessage = screenReaderStatus({
127
+ count: focusableOptions.length
128
+ });
129
+ resultsMsg = messages.onFilter({
130
+ inputValue,
131
+ resultsMessage
132
+ });
137
133
  }
138
134
  return resultsMsg;
139
135
  }, [focusableOptions, inputValue, menuIsOpen, messages, options, screenReaderStatus, isLoading]);
@@ -160,9 +156,9 @@ const LiveRegion = props => {
160
156
  }, [ariaLabel, focusedOption, focusedValue, isMulti, isOptionDisabled, isSearchable, menuIsOpen, messages, selectValue, tabSelectsValue, isInitialFocus]);
161
157
  const ScreenReaderText = jsx(Fragment, null, jsx("span", {
162
158
  id: "aria-selection"
163
- }, ariaSelected), !fg('design_system_select-a11y-improvement') && jsx(React.Fragment, null, jsx("span", {
159
+ }, ariaSelected), jsx("span", {
164
160
  id: "aria-results"
165
- }, ariaResults), jsx("span", {
161
+ }, ariaResults), !fg('design_system_select-a11y-improvement') && jsx(React.Fragment, null, jsx("span", {
166
162
  id: "aria-focused"
167
163
  }, ariaFocused), jsx("span", {
168
164
  id: "aria-guidance"
@@ -7,6 +7,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
7
7
  import { formatGroupLabel as formatGroupLabelBuiltin, getOptionLabel as getOptionLabelBuiltin, getOptionValue as getOptionValueBuiltin, isOptionDisabled as isOptionDisabledBuiltin } from './builtins';
8
8
  import { defaultComponents } from './components';
9
9
  import { DummyInput, RequiredInput, ScrollManager } from './components/internal';
10
+ import { NotifyOpenLayerObserver } from './components/internal/notify-open-layer-observer';
10
11
  import LiveRegion from './components/live-region';
11
12
  import { MenuPlacer } from './components/menu';
12
13
  import { createFilter } from './filters';
@@ -802,10 +803,16 @@ export default class Select extends Component {
802
803
  }
803
804
  event.preventDefault();
804
805
  });
806
+ _defineProperty(this, "handleOpenLayerObserverCloseSignal", () => {
807
+ if (!fg('platform_dst_layer_observer_select')) {
808
+ return;
809
+ }
810
+ this.onMenuClose();
811
+ });
805
812
  this.state.instancePrefix = 'react-select-' + (this.props.instanceId || ++instanceId);
806
813
  this.state.selectValue = cleanValue(_props.value);
807
814
  // Set focusedOption if menuIsOpen is set on init (e.g. defaultMenuIsOpen)
808
- if (_props.menuIsOpen && this.state.selectValue.length) {
815
+ if (_props.menuIsOpen) {
809
816
  const focusableOptionsWithIds = this.getFocusableOptionsWithIds();
810
817
  const focusableOptions = this.buildFocusableOptions();
811
818
  const optionIndex = focusableOptions.indexOf(this.state.selectValue[0]);
@@ -1647,6 +1654,26 @@ export default class Select extends Component {
1647
1654
  menuPosition,
1648
1655
  menuShouldScrollIntoView
1649
1656
  };
1657
+ const calculateListboxLabel = () => {
1658
+ var _this$inputRef;
1659
+ // First in name calculation, overwrites aria-label
1660
+ if (labelId) {
1661
+ return {
1662
+ 'aria-labelledby': labelId
1663
+ };
1664
+ }
1665
+ // Second in name calcuation, overwrites everything else except aria-labelledby
1666
+ if (label) {
1667
+ return {
1668
+ 'aria-label': label
1669
+ };
1670
+ }
1671
+ // Fallback if no label or labelId is provided, might catch label via <label for> otherwise
1672
+ // will most likely not have an accessible name
1673
+ return {
1674
+ 'aria-labelledby': ((_this$inputRef = this.inputRef) === null || _this$inputRef === void 0 ? void 0 : _this$inputRef.id) || this.getElementId('input')
1675
+ };
1676
+ };
1650
1677
  const menuElement = /*#__PURE__*/React.createElement(MenuPlacer, _extends({}, commonProps, menuPlacementProps), ({
1651
1678
  ref,
1652
1679
  placerProps: {
@@ -1670,31 +1697,25 @@ export default class Select extends Component {
1670
1697
  onTopArrive: onMenuScrollToTop,
1671
1698
  onBottomArrive: onMenuScrollToBottom,
1672
1699
  lockEnabled: menuShouldBlockScroll
1673
- }, scrollTargetRef => {
1674
- var _this$inputRef;
1675
- return /*#__PURE__*/React.createElement(MenuList, _extends({}, commonProps, {
1676
- innerRef: instance => {
1677
- this.getMenuListRef(instance);
1678
- scrollTargetRef(instance);
1679
- },
1680
- innerProps: {
1681
- role: 'listbox',
1682
- 'aria-multiselectable': (this.isVoiceOver || !commonProps.isMulti) && fg('design_system_select-a11y-improvement') ? undefined : commonProps.isMulti,
1683
- id: this.getElementId('listbox'),
1684
- ...(testId && {
1685
- 'data-testid': `${testId}-select--listbox`
1686
- }),
1687
- // add aditional label on listbox when ff is on
1688
- ...(fg('design_system_select-a11y-improvement') && {
1689
- 'aria-label': label,
1690
- 'aria-labelledby': `${labelId || ((_this$inputRef = this.inputRef) === null || _this$inputRef === void 0 ? void 0 : _this$inputRef.id) || this.getElementId('input')}`
1691
- })
1692
- },
1693
- isLoading: isLoading,
1694
- maxHeight: maxHeight,
1695
- focusedOption: focusedOption
1696
- }), menuUI);
1697
- })));
1700
+ }, scrollTargetRef => /*#__PURE__*/React.createElement(MenuList, _extends({}, commonProps, {
1701
+ innerRef: instance => {
1702
+ this.getMenuListRef(instance);
1703
+ scrollTargetRef(instance);
1704
+ },
1705
+ innerProps: {
1706
+ role: 'listbox',
1707
+ 'aria-multiselectable': (this.isVoiceOver || !commonProps.isMulti) && fg('design_system_select-a11y-improvement') ? undefined : commonProps.isMulti,
1708
+ id: this.getElementId('listbox'),
1709
+ ...(testId && {
1710
+ 'data-testid': `${testId}-select--listbox`
1711
+ }),
1712
+ // add aditional label on listbox when ff is on
1713
+ ...(fg('design_system_select-a11y-improvement') && calculateListboxLabel())
1714
+ },
1715
+ isLoading: isLoading,
1716
+ maxHeight: maxHeight,
1717
+ focusedOption: focusedOption
1718
+ }), menuUI))));
1698
1719
 
1699
1720
  // positioning behaviour is almost identical for portalled and fixed,
1700
1721
  // so we use the same component. the actual portalling logic is forked
@@ -1853,7 +1874,10 @@ export default class Select extends Component {
1853
1874
  'data-testid': `${testId}-select--indicators-container`
1854
1875
  })
1855
1876
  }
1856
- }), this.renderClearIndicator(), this.renderLoadingIndicator(), this.renderDropdownIndicator())), this.renderMenu(), this.renderFormField());
1877
+ }), this.renderClearIndicator(), this.renderLoadingIndicator(), this.renderDropdownIndicator())), this.renderMenu(), this.renderFormField(), /*#__PURE__*/React.createElement(NotifyOpenLayerObserver, {
1878
+ isOpen: fg('platform_dst_layer_observer_select') && this.props.menuIsOpen,
1879
+ onClose: this.handleOpenLayerObserverCloseSignal
1880
+ }));
1857
1881
  }
1858
1882
  }
1859
1883
  _defineProperty(Select, "defaultProps", defaultProps);
@@ -0,0 +1,15 @@
1
+ import { useNotifyOpenLayerObserver } from '@atlaskit/layering/experimental/open-layer-observer';
2
+ /**
3
+ * Functional component wrapper around `useNotifyOpenLayerObserver`.
4
+ *
5
+ * This is needed as Select is a class component, which cannot use hooks directly.
6
+ */
7
+ export function NotifyOpenLayerObserver(_ref) {
8
+ var isOpen = _ref.isOpen,
9
+ onClose = _ref.onClose;
10
+ useNotifyOpenLayerObserver({
11
+ isOpen: isOpen,
12
+ onClose: onClose
13
+ });
14
+ return null;
15
+ }
@@ -120,17 +120,13 @@ var LiveRegion = function LiveRegion(props) {
120
120
  var ariaResults = useMemo(function () {
121
121
  var resultsMsg = '';
122
122
  if (menuIsOpen && options.length && !isLoading && messages.onFilter) {
123
- var shouldAnnounceAvailableResults = !focusableOptions.length;
124
- if (shouldAnnounceAvailableResults && fg('design_system_select-a11y-improvement') || !fg('design_system_select-a11y-improvement')) {
125
- // only announce no option results when ff is on
126
- var resultsMessage = screenReaderStatus({
127
- count: focusableOptions.length
128
- });
129
- resultsMsg = messages.onFilter({
130
- inputValue: inputValue,
131
- resultsMessage: resultsMessage
132
- });
133
- }
123
+ var resultsMessage = screenReaderStatus({
124
+ count: focusableOptions.length
125
+ });
126
+ resultsMsg = messages.onFilter({
127
+ inputValue: inputValue,
128
+ resultsMessage: resultsMessage
129
+ });
134
130
  }
135
131
  return resultsMsg;
136
132
  }, [focusableOptions, inputValue, menuIsOpen, messages, options, screenReaderStatus, isLoading]);
@@ -157,9 +153,9 @@ var LiveRegion = function LiveRegion(props) {
157
153
  }, [ariaLabel, focusedOption, focusedValue, isMulti, isOptionDisabled, isSearchable, menuIsOpen, messages, selectValue, tabSelectsValue, isInitialFocus]);
158
154
  var ScreenReaderText = jsx(Fragment, null, jsx("span", {
159
155
  id: "aria-selection"
160
- }, ariaSelected), !fg('design_system_select-a11y-improvement') && jsx(React.Fragment, null, jsx("span", {
156
+ }, ariaSelected), jsx("span", {
161
157
  id: "aria-results"
162
- }, ariaResults), jsx("span", {
158
+ }, ariaResults), !fg('design_system_select-a11y-improvement') && jsx(React.Fragment, null, jsx("span", {
163
159
  id: "aria-focused"
164
160
  }, ariaFocused), jsx("span", {
165
161
  id: "aria-guidance"
@@ -18,6 +18,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
18
18
  import { formatGroupLabel as formatGroupLabelBuiltin, getOptionLabel as getOptionLabelBuiltin, getOptionValue as getOptionValueBuiltin, isOptionDisabled as isOptionDisabledBuiltin } from './builtins';
19
19
  import { defaultComponents } from './components';
20
20
  import { DummyInput, RequiredInput, ScrollManager } from './components/internal';
21
+ import { NotifyOpenLayerObserver } from './components/internal/notify-open-layer-observer';
21
22
  import LiveRegion from './components/live-region';
22
23
  import { MenuPlacer } from './components/menu';
23
24
  import { createFilter } from './filters';
@@ -817,10 +818,16 @@ var Select = /*#__PURE__*/function (_Component) {
817
818
  }
818
819
  event.preventDefault();
819
820
  });
821
+ _defineProperty(_this, "handleOpenLayerObserverCloseSignal", function () {
822
+ if (!fg('platform_dst_layer_observer_select')) {
823
+ return;
824
+ }
825
+ _this.onMenuClose();
826
+ });
820
827
  _this.state.instancePrefix = 'react-select-' + (_this.props.instanceId || ++instanceId);
821
828
  _this.state.selectValue = cleanValue(_props.value);
822
829
  // Set focusedOption if menuIsOpen is set on init (e.g. defaultMenuIsOpen)
823
- if (_props.menuIsOpen && _this.state.selectValue.length) {
830
+ if (_props.menuIsOpen) {
824
831
  var focusableOptionsWithIds = _this.getFocusableOptionsWithIds();
825
832
  var focusableOptions = _this.buildFocusableOptions();
826
833
  var optionIndex = focusableOptions.indexOf(_this.state.selectValue[0]);
@@ -1605,6 +1612,26 @@ var Select = /*#__PURE__*/function (_Component) {
1605
1612
  menuPosition: menuPosition,
1606
1613
  menuShouldScrollIntoView: menuShouldScrollIntoView
1607
1614
  };
1615
+ var calculateListboxLabel = function calculateListboxLabel() {
1616
+ var _this4$inputRef;
1617
+ // First in name calculation, overwrites aria-label
1618
+ if (labelId) {
1619
+ return {
1620
+ 'aria-labelledby': labelId
1621
+ };
1622
+ }
1623
+ // Second in name calcuation, overwrites everything else except aria-labelledby
1624
+ if (label) {
1625
+ return {
1626
+ 'aria-label': label
1627
+ };
1628
+ }
1629
+ // Fallback if no label or labelId is provided, might catch label via <label for> otherwise
1630
+ // will most likely not have an accessible name
1631
+ return {
1632
+ 'aria-labelledby': ((_this4$inputRef = _this4.inputRef) === null || _this4$inputRef === void 0 ? void 0 : _this4$inputRef.id) || _this4.getElementId('input')
1633
+ };
1634
+ };
1608
1635
  var menuElement = /*#__PURE__*/React.createElement(MenuPlacer, _extends({}, commonProps, menuPlacementProps), function (_ref4) {
1609
1636
  var ref = _ref4.ref,
1610
1637
  _ref4$placerProps = _ref4.placerProps,
@@ -1627,7 +1654,6 @@ var Select = /*#__PURE__*/function (_Component) {
1627
1654
  onBottomArrive: onMenuScrollToBottom,
1628
1655
  lockEnabled: menuShouldBlockScroll
1629
1656
  }, function (scrollTargetRef) {
1630
- var _this4$inputRef;
1631
1657
  return /*#__PURE__*/React.createElement(MenuList, _extends({}, commonProps, {
1632
1658
  innerRef: function innerRef(instance) {
1633
1659
  _this4.getMenuListRef(instance);
@@ -1639,10 +1665,7 @@ var Select = /*#__PURE__*/function (_Component) {
1639
1665
  id: _this4.getElementId('listbox')
1640
1666
  }, testId && {
1641
1667
  'data-testid': "".concat(testId, "-select--listbox")
1642
- }), fg('design_system_select-a11y-improvement') && {
1643
- 'aria-label': label,
1644
- 'aria-labelledby': "".concat(labelId || ((_this4$inputRef = _this4.inputRef) === null || _this4$inputRef === void 0 ? void 0 : _this4$inputRef.id) || _this4.getElementId('input'))
1645
- }),
1668
+ }), fg('design_system_select-a11y-improvement') && calculateListboxLabel()),
1646
1669
  isLoading: isLoading,
1647
1670
  maxHeight: maxHeight,
1648
1671
  focusedOption: focusedOption
@@ -1806,7 +1829,10 @@ var Select = /*#__PURE__*/function (_Component) {
1806
1829
  innerProps: _objectSpread({}, testId && {
1807
1830
  'data-testid': "".concat(testId, "-select--indicators-container")
1808
1831
  })
1809
- }), this.renderClearIndicator(), this.renderLoadingIndicator(), this.renderDropdownIndicator())), this.renderMenu(), this.renderFormField());
1832
+ }), this.renderClearIndicator(), this.renderLoadingIndicator(), this.renderDropdownIndicator())), this.renderMenu(), this.renderFormField(), /*#__PURE__*/React.createElement(NotifyOpenLayerObserver, {
1833
+ isOpen: fg('platform_dst_layer_observer_select') && this.props.menuIsOpen,
1834
+ onClose: this.handleOpenLayerObserverCloseSignal
1835
+ }));
1810
1836
  }
1811
1837
  }], [{
1812
1838
  key: "getDerivedStateFromProps",
@@ -0,0 +1,9 @@
1
+ import { useNotifyOpenLayerObserver } from '@atlaskit/layering/experimental/open-layer-observer';
2
+ type NotifyOpenLayerObserverProps = Parameters<typeof useNotifyOpenLayerObserver>[0];
3
+ /**
4
+ * Functional component wrapper around `useNotifyOpenLayerObserver`.
5
+ *
6
+ * This is needed as Select is a class component, which cannot use hooks directly.
7
+ */
8
+ export declare function NotifyOpenLayerObserver({ isOpen, onClose }: NotifyOpenLayerObserverProps): null;
9
+ export {};
@@ -694,6 +694,7 @@ export default class Select<Option = unknown, IsMulti extends boolean = false, G
694
694
  renderFormField(): React.JSX.Element | undefined;
695
695
  renderLiveRegion(): React.JSX.Element;
696
696
  renderMultiselectMessage(): React.JSX.Element;
697
+ handleOpenLayerObserverCloseSignal: () => void;
697
698
  render(): React.JSX.Element;
698
699
  }
699
700
  export type PublicBaseSelectProps<Option, IsMulti extends boolean, Group extends GroupBase<Option>> = JSX.LibraryManagedAttributes<typeof Select, SelectProps<Option, IsMulti, Group>>;
@@ -0,0 +1,9 @@
1
+ import { useNotifyOpenLayerObserver } from '@atlaskit/layering/experimental/open-layer-observer';
2
+ type NotifyOpenLayerObserverProps = Parameters<typeof useNotifyOpenLayerObserver>[0];
3
+ /**
4
+ * Functional component wrapper around `useNotifyOpenLayerObserver`.
5
+ *
6
+ * This is needed as Select is a class component, which cannot use hooks directly.
7
+ */
8
+ export declare function NotifyOpenLayerObserver({ isOpen, onClose }: NotifyOpenLayerObserverProps): null;
9
+ export {};
@@ -694,6 +694,7 @@ export default class Select<Option = unknown, IsMulti extends boolean = false, G
694
694
  renderFormField(): React.JSX.Element | undefined;
695
695
  renderLiveRegion(): React.JSX.Element;
696
696
  renderMultiselectMessage(): React.JSX.Element;
697
+ handleOpenLayerObserverCloseSignal: () => void;
697
698
  render(): React.JSX.Element;
698
699
  }
699
700
  export type PublicBaseSelectProps<Option, IsMulti extends boolean, Group extends GroupBase<Option>> = JSX.LibraryManagedAttributes<typeof Select, SelectProps<Option, IsMulti, Group>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-select",
3
- "version": "2.0.6",
3
+ "version": "2.1.0",
4
4
  "description": "A forked version of react-select to only be used in atlaskit/select",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -30,11 +30,12 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@atlaskit/ds-lib": "^4.0.0",
33
- "@atlaskit/icon": "^25.0.0",
33
+ "@atlaskit/icon": "^25.5.0",
34
+ "@atlaskit/layering": "^2.1.0",
34
35
  "@atlaskit/platform-feature-flags": "^1.1.0",
35
- "@atlaskit/primitives": "^14.1.0",
36
+ "@atlaskit/primitives": "^14.3.0",
36
37
  "@atlaskit/spinner": "^18.0.0",
37
- "@atlaskit/tokens": "^4.5.0",
38
+ "@atlaskit/tokens": "^4.6.0",
38
39
  "@babel/runtime": "^7.0.0",
39
40
  "@emotion/react": "^11.7.1",
40
41
  "@floating-ui/dom": "^1.0.1",
@@ -69,6 +70,9 @@
69
70
  },
70
71
  "platform-visual-refresh-icons-legacy-facade": {
71
72
  "type": "boolean"
73
+ },
74
+ "platform_dst_layer_observer_select": {
75
+ "type": "boolean"
72
76
  }
73
77
  },
74
78
  "techstack": {