What problem does this feature solve?
If the user moves between TreeSelect options using arrow keys, the screenreader will always read out the value of the active node. It would be much better for accessibility (and more flexible), if I as a developer could decide to use labels for aria-live content instead of the values.
What does the proposed API look like?
New prop would be labelInAriaLive
, and it would be false
by default. This prob would then be used to decide whether to use the value or label of the selected item, when rendering the aria-live tag of the component.
Using the component with the implemented feature:
import React, { useState } from 'react';
import { TreeSelect } from 'antd';
const { TreeNode } = TreeSelect;
const Demo = () => {
const [value, setValue] = useState(undefined);
const onChange = () => {
setValue(value);
};
return (
<TreeSelect
showSearch
style={{ width: '100%' }}
value={value}
labelInAriaLive={true} // Here's the API change: default would be false
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
placeholder="Please select"
allowClear
treeDefaultExpandAll
onChange={onChange}
>
<TreeNode value="parent 1" title="parent 1">
<TreeNode value="parent 1-0" title="parent 1-0">
<TreeNode value="leaf1" title="leaf1" />
<TreeNode value="leaf2" title="leaf2" />
</TreeNode>
<TreeNode value="parent 1-1" title="parent 1-1">
<TreeNode value="leaf3" title={<b style={{ color: '#08c' }}>leaf3</b>} />
</TreeNode>
</TreeNode>
</TreeSelect>
);
};
export default Demo;
3条答案
按热度按时间pxy2qtax1#
You may look for issues:
🤖 By issues-similarity-analysis
neskvpey2#
From
antd\dist\antd.js
:The new prop would control the last row? Instead of reading
value
a screen reader would readtitle
? This is very welcome improvement to accessibility astitle
is often more meaningful thanvalue
(usually some kind of ID, key, or hash).oymdgrw73#
Looks like this feature needs to be implemented in rc-treeselect. I made a feature-request there: react-component/tree-select#412