-
Notifications
You must be signed in to change notification settings - Fork 841
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EuiSelectable] Add a mixed state to
EuiSelectableListItem
that ren…
…ders a new icon and SR-only text (#6774) * Swapped icon assignment flow to use switch/case. * Added logic for mixed option state. Added SR text. * Updated a11y language for exclusions. Added snapshot and a11y tests. * Added changelog and two updated snapshots. * Updating docs for checked: 'mixed' value. * Fixed linting errors in src-docs. * Updated unit test snapshot. * Update src/components/selectable/selectable_option.tsx Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> * Update src/components/selectable/selectable_option.tsx Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> * Refactoring allowExceptions logic to switch case. * Updated tests, documentation to be more granular. * Added note about aria-checked mixed with MDN links. * Update upcoming_changelogs/6774.md Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> * Refactor `aria-checked` to work for all eligible roles + `aria-disabled` and `aria-checked` is valid - do not return undefined if disabled + `aria-checked` mixed is invalid for certain roles - return false if so * Update unit tests - add describe block tests for `role` and `aria-checked` - add describe blocks for `checked` - switch to RTL render * Massive screen reader text cleanup/refactor - DRY out repeated i18n tokens/strings - Make branching easier to follow (hopefully...) - Fix some incorrect branching logic leading to missing SR text (namely non-exclusion mixed) - Improve SR reading by using a period instead of a hyphen (at least for FF+VO) - Add more unit tests to snapshot branching output + rename various vars to be slightly clearer * [PR feedback] Docs - Remove `allowExclusions` from example - while they work together, it's unlikely consumers will use both, and we should focus on just mixed options for this demo to isolate concerns - Document when consumers would want to use this state - Add button that allows resetting mixed state display - Fix snippet * [pr feedback] minor type cleanup * fix snippet * Escaped quotes for lint error. * code editor valid quotes --------- Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> Co-authored-by: Constance Chen <constance.chen.3@gmail.com>
- Loading branch information
1 parent
cfb6d58
commit f8bc384
Showing
13 changed files
with
1,515 additions
and
1,131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import React, { useState } from 'react'; | ||
|
||
import { | ||
EuiSelectable, | ||
EuiSelectableOption, | ||
EuiButton, | ||
EuiSpacer, | ||
} from '../../../../src'; | ||
|
||
const initialOptions: EuiSelectableOption[] = [ | ||
{ | ||
label: 'Titan', | ||
'data-test-subj': 'titanOption', | ||
checked: 'mixed', | ||
}, | ||
{ | ||
label: 'Enceladus is disabled', | ||
disabled: true, | ||
}, | ||
{ | ||
label: 'Mimas', | ||
checked: 'on', | ||
}, | ||
{ | ||
label: 'Dione', | ||
checked: 'mixed', | ||
}, | ||
{ | ||
label: 'Iapetus', | ||
}, | ||
{ | ||
label: 'Phoebe', | ||
checked: 'mixed', | ||
}, | ||
{ | ||
label: 'Rhea', | ||
}, | ||
{ | ||
label: | ||
"Pandora is one of Saturn's moons, named for a Titaness of Greek mythology", | ||
}, | ||
{ | ||
label: 'Tethys', | ||
}, | ||
{ | ||
label: 'Hyperion', | ||
}, | ||
]; | ||
|
||
export default () => { | ||
const [options, setOptions] = useState(initialOptions); | ||
|
||
return ( | ||
<> | ||
<EuiSelectable | ||
aria-label="Example of Selectable supporting mixed state" | ||
options={options} | ||
onChange={(newOptions) => setOptions(newOptions)} | ||
> | ||
{(list) => list} | ||
</EuiSelectable> | ||
<EuiSpacer size="s" /> | ||
<EuiButton onClick={() => setOptions(initialOptions)}> | ||
Reset mixed options | ||
</EuiButton> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.