@atlaskit/react-select 2.0.6 → 2.0.7
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 +8 -0
- package/dist/cjs/components/live-region.js +9 -13
- package/dist/cjs/select.js +22 -6
- package/dist/es2019/components/live-region.js +9 -13
- package/dist/es2019/select.js +40 -26
- package/dist/esm/components/live-region.js +9 -13
- package/dist/esm/select.js +22 -6
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/react-select
|
|
2
2
|
|
|
3
|
+
## 2.0.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#131835](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/131835)
|
|
8
|
+
[`11b3a9f6a407e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/11b3a9f6a407e) -
|
|
9
|
+
[Popup Select] Improve assistive technology support by reducing reliance on live regions.
|
|
10
|
+
|
|
3
11
|
## 2.0.6
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -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
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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),
|
|
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"
|
package/dist/cjs/select.js
CHANGED
|
@@ -829,7 +829,7 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
829
829
|
_this.state.instancePrefix = 'react-select-' + (_this.props.instanceId || ++instanceId);
|
|
830
830
|
_this.state.selectValue = (0, _utils.cleanValue)(_props.value);
|
|
831
831
|
// Set focusedOption if menuIsOpen is set on init (e.g. defaultMenuIsOpen)
|
|
832
|
-
if (_props.menuIsOpen
|
|
832
|
+
if (_props.menuIsOpen) {
|
|
833
833
|
var focusableOptionsWithIds = _this.getFocusableOptionsWithIds();
|
|
834
834
|
var focusableOptions = _this.buildFocusableOptions();
|
|
835
835
|
var optionIndex = focusableOptions.indexOf(_this.state.selectValue[0]);
|
|
@@ -1614,6 +1614,26 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
1614
1614
|
menuPosition: menuPosition,
|
|
1615
1615
|
menuShouldScrollIntoView: menuShouldScrollIntoView
|
|
1616
1616
|
};
|
|
1617
|
+
var calculateListboxLabel = function calculateListboxLabel() {
|
|
1618
|
+
var _this4$inputRef;
|
|
1619
|
+
// First in name calculation, overwrites aria-label
|
|
1620
|
+
if (labelId) {
|
|
1621
|
+
return {
|
|
1622
|
+
'aria-labelledby': labelId
|
|
1623
|
+
};
|
|
1624
|
+
}
|
|
1625
|
+
// Second in name calcuation, overwrites everything else except aria-labelledby
|
|
1626
|
+
if (label) {
|
|
1627
|
+
return {
|
|
1628
|
+
'aria-label': label
|
|
1629
|
+
};
|
|
1630
|
+
}
|
|
1631
|
+
// Fallback if no label or labelId is provided, might catch label via <label for> otherwise
|
|
1632
|
+
// will most likely not have an accessible name
|
|
1633
|
+
return {
|
|
1634
|
+
'aria-labelledby': ((_this4$inputRef = _this4.inputRef) === null || _this4$inputRef === void 0 ? void 0 : _this4$inputRef.id) || _this4.getElementId('input')
|
|
1635
|
+
};
|
|
1636
|
+
};
|
|
1617
1637
|
var menuElement = /*#__PURE__*/_react.default.createElement(_menu.MenuPlacer, (0, _extends2.default)({}, commonProps, menuPlacementProps), function (_ref4) {
|
|
1618
1638
|
var ref = _ref4.ref,
|
|
1619
1639
|
_ref4$placerProps = _ref4.placerProps,
|
|
@@ -1636,7 +1656,6 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
1636
1656
|
onBottomArrive: onMenuScrollToBottom,
|
|
1637
1657
|
lockEnabled: menuShouldBlockScroll
|
|
1638
1658
|
}, function (scrollTargetRef) {
|
|
1639
|
-
var _this4$inputRef;
|
|
1640
1659
|
return /*#__PURE__*/_react.default.createElement(MenuList, (0, _extends2.default)({}, commonProps, {
|
|
1641
1660
|
innerRef: function innerRef(instance) {
|
|
1642
1661
|
_this4.getMenuListRef(instance);
|
|
@@ -1648,10 +1667,7 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
1648
1667
|
id: _this4.getElementId('listbox')
|
|
1649
1668
|
}, testId && {
|
|
1650
1669
|
'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
|
-
}),
|
|
1670
|
+
}), (0, _platformFeatureFlags.fg)('design_system_select-a11y-improvement') && calculateListboxLabel()),
|
|
1655
1671
|
isLoading: isLoading,
|
|
1656
1672
|
maxHeight: maxHeight,
|
|
1657
1673
|
focusedOption: focusedOption
|
|
@@ -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
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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),
|
|
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"
|
package/dist/es2019/select.js
CHANGED
|
@@ -805,7 +805,7 @@ export default class Select extends Component {
|
|
|
805
805
|
this.state.instancePrefix = 'react-select-' + (this.props.instanceId || ++instanceId);
|
|
806
806
|
this.state.selectValue = cleanValue(_props.value);
|
|
807
807
|
// Set focusedOption if menuIsOpen is set on init (e.g. defaultMenuIsOpen)
|
|
808
|
-
if (_props.menuIsOpen
|
|
808
|
+
if (_props.menuIsOpen) {
|
|
809
809
|
const focusableOptionsWithIds = this.getFocusableOptionsWithIds();
|
|
810
810
|
const focusableOptions = this.buildFocusableOptions();
|
|
811
811
|
const optionIndex = focusableOptions.indexOf(this.state.selectValue[0]);
|
|
@@ -1647,6 +1647,26 @@ export default class Select extends Component {
|
|
|
1647
1647
|
menuPosition,
|
|
1648
1648
|
menuShouldScrollIntoView
|
|
1649
1649
|
};
|
|
1650
|
+
const calculateListboxLabel = () => {
|
|
1651
|
+
var _this$inputRef;
|
|
1652
|
+
// First in name calculation, overwrites aria-label
|
|
1653
|
+
if (labelId) {
|
|
1654
|
+
return {
|
|
1655
|
+
'aria-labelledby': labelId
|
|
1656
|
+
};
|
|
1657
|
+
}
|
|
1658
|
+
// Second in name calcuation, overwrites everything else except aria-labelledby
|
|
1659
|
+
if (label) {
|
|
1660
|
+
return {
|
|
1661
|
+
'aria-label': label
|
|
1662
|
+
};
|
|
1663
|
+
}
|
|
1664
|
+
// Fallback if no label or labelId is provided, might catch label via <label for> otherwise
|
|
1665
|
+
// will most likely not have an accessible name
|
|
1666
|
+
return {
|
|
1667
|
+
'aria-labelledby': ((_this$inputRef = this.inputRef) === null || _this$inputRef === void 0 ? void 0 : _this$inputRef.id) || this.getElementId('input')
|
|
1668
|
+
};
|
|
1669
|
+
};
|
|
1650
1670
|
const menuElement = /*#__PURE__*/React.createElement(MenuPlacer, _extends({}, commonProps, menuPlacementProps), ({
|
|
1651
1671
|
ref,
|
|
1652
1672
|
placerProps: {
|
|
@@ -1670,31 +1690,25 @@ export default class Select extends Component {
|
|
|
1670
1690
|
onTopArrive: onMenuScrollToTop,
|
|
1671
1691
|
onBottomArrive: onMenuScrollToBottom,
|
|
1672
1692
|
lockEnabled: menuShouldBlockScroll
|
|
1673
|
-
}, scrollTargetRef => {
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
},
|
|
1693
|
-
isLoading: isLoading,
|
|
1694
|
-
maxHeight: maxHeight,
|
|
1695
|
-
focusedOption: focusedOption
|
|
1696
|
-
}), menuUI);
|
|
1697
|
-
})));
|
|
1693
|
+
}, scrollTargetRef => /*#__PURE__*/React.createElement(MenuList, _extends({}, commonProps, {
|
|
1694
|
+
innerRef: instance => {
|
|
1695
|
+
this.getMenuListRef(instance);
|
|
1696
|
+
scrollTargetRef(instance);
|
|
1697
|
+
},
|
|
1698
|
+
innerProps: {
|
|
1699
|
+
role: 'listbox',
|
|
1700
|
+
'aria-multiselectable': (this.isVoiceOver || !commonProps.isMulti) && fg('design_system_select-a11y-improvement') ? undefined : commonProps.isMulti,
|
|
1701
|
+
id: this.getElementId('listbox'),
|
|
1702
|
+
...(testId && {
|
|
1703
|
+
'data-testid': `${testId}-select--listbox`
|
|
1704
|
+
}),
|
|
1705
|
+
// add aditional label on listbox when ff is on
|
|
1706
|
+
...(fg('design_system_select-a11y-improvement') && calculateListboxLabel())
|
|
1707
|
+
},
|
|
1708
|
+
isLoading: isLoading,
|
|
1709
|
+
maxHeight: maxHeight,
|
|
1710
|
+
focusedOption: focusedOption
|
|
1711
|
+
}), menuUI))));
|
|
1698
1712
|
|
|
1699
1713
|
// positioning behaviour is almost identical for portalled and fixed,
|
|
1700
1714
|
// so we use the same component. the actual portalling logic is forked
|
|
@@ -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
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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),
|
|
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"
|
package/dist/esm/select.js
CHANGED
|
@@ -820,7 +820,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
820
820
|
_this.state.instancePrefix = 'react-select-' + (_this.props.instanceId || ++instanceId);
|
|
821
821
|
_this.state.selectValue = cleanValue(_props.value);
|
|
822
822
|
// Set focusedOption if menuIsOpen is set on init (e.g. defaultMenuIsOpen)
|
|
823
|
-
if (_props.menuIsOpen
|
|
823
|
+
if (_props.menuIsOpen) {
|
|
824
824
|
var focusableOptionsWithIds = _this.getFocusableOptionsWithIds();
|
|
825
825
|
var focusableOptions = _this.buildFocusableOptions();
|
|
826
826
|
var optionIndex = focusableOptions.indexOf(_this.state.selectValue[0]);
|
|
@@ -1605,6 +1605,26 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
1605
1605
|
menuPosition: menuPosition,
|
|
1606
1606
|
menuShouldScrollIntoView: menuShouldScrollIntoView
|
|
1607
1607
|
};
|
|
1608
|
+
var calculateListboxLabel = function calculateListboxLabel() {
|
|
1609
|
+
var _this4$inputRef;
|
|
1610
|
+
// First in name calculation, overwrites aria-label
|
|
1611
|
+
if (labelId) {
|
|
1612
|
+
return {
|
|
1613
|
+
'aria-labelledby': labelId
|
|
1614
|
+
};
|
|
1615
|
+
}
|
|
1616
|
+
// Second in name calcuation, overwrites everything else except aria-labelledby
|
|
1617
|
+
if (label) {
|
|
1618
|
+
return {
|
|
1619
|
+
'aria-label': label
|
|
1620
|
+
};
|
|
1621
|
+
}
|
|
1622
|
+
// Fallback if no label or labelId is provided, might catch label via <label for> otherwise
|
|
1623
|
+
// will most likely not have an accessible name
|
|
1624
|
+
return {
|
|
1625
|
+
'aria-labelledby': ((_this4$inputRef = _this4.inputRef) === null || _this4$inputRef === void 0 ? void 0 : _this4$inputRef.id) || _this4.getElementId('input')
|
|
1626
|
+
};
|
|
1627
|
+
};
|
|
1608
1628
|
var menuElement = /*#__PURE__*/React.createElement(MenuPlacer, _extends({}, commonProps, menuPlacementProps), function (_ref4) {
|
|
1609
1629
|
var ref = _ref4.ref,
|
|
1610
1630
|
_ref4$placerProps = _ref4.placerProps,
|
|
@@ -1627,7 +1647,6 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
1627
1647
|
onBottomArrive: onMenuScrollToBottom,
|
|
1628
1648
|
lockEnabled: menuShouldBlockScroll
|
|
1629
1649
|
}, function (scrollTargetRef) {
|
|
1630
|
-
var _this4$inputRef;
|
|
1631
1650
|
return /*#__PURE__*/React.createElement(MenuList, _extends({}, commonProps, {
|
|
1632
1651
|
innerRef: function innerRef(instance) {
|
|
1633
1652
|
_this4.getMenuListRef(instance);
|
|
@@ -1639,10 +1658,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
1639
1658
|
id: _this4.getElementId('listbox')
|
|
1640
1659
|
}, testId && {
|
|
1641
1660
|
'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
|
-
}),
|
|
1661
|
+
}), fg('design_system_select-a11y-improvement') && calculateListboxLabel()),
|
|
1646
1662
|
isLoading: isLoading,
|
|
1647
1663
|
maxHeight: maxHeight,
|
|
1648
1664
|
focusedOption: focusedOption
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/react-select",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
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,9 +30,9 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@atlaskit/ds-lib": "^4.0.0",
|
|
33
|
-
"@atlaskit/icon": "^25.
|
|
33
|
+
"@atlaskit/icon": "^25.1.0",
|
|
34
34
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
35
|
-
"@atlaskit/primitives": "^14.
|
|
35
|
+
"@atlaskit/primitives": "^14.2.0",
|
|
36
36
|
"@atlaskit/spinner": "^18.0.0",
|
|
37
37
|
"@atlaskit/tokens": "^4.5.0",
|
|
38
38
|
"@babel/runtime": "^7.0.0",
|