-
Notifications
You must be signed in to change notification settings - Fork 55
fix(dropdown): applied roving tabindex technique to selected dropdown items #1004
Conversation
@@ -90,7 +90,10 @@ class DropdownSelectedItem extends UIComponent<ReactProps<DropdownSelectedItemPr | |||
|
|||
componentDidUpdate(prevProps: DropdownSelectedItemProps) { | |||
if (!prevProps.active && this.props.active) { | |||
this.itemRef.current.setAttribute('tabindex', '0') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We definitely should start extracting behavior for the Dropdown component, we have too much coupling of accessibility concerns in the component... That way we would test this things separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved, just update the changelog, and let's start with extracting these things to behavior
Codecov Report
@@ Coverage Diff @@
## master #1004 +/- ##
=========================================
+ Coverage 81.37% 81.5% +0.12%
=========================================
Files 673 673
Lines 8699 8700 +1
Branches 1475 1476 +1
=========================================
+ Hits 7079 7091 +12
+ Misses 1605 1594 -11
Partials 15 15
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What it is the reason to use DOM API?
<Label tabIndex={active ? 0 : -1} />
Without it, when in a Popup and a selected item is focused, shift tab will make focus escape the Popup, as FocusTrapZone will not handle it as first focusable item in the Popup (due to the lack of tabindex="0").
Also it does not hurt to be able to come back to the selected item via tab/shift tab once you tabbed/shift tabbed away.