Skip to content

RSP-1496: RadioGroup roving tabIndex#320

Merged
devongovett merged 11 commits intomasterfrom
RSP-1496
Apr 1, 2020
Merged

RSP-1496: RadioGroup roving tabIndex#320
devongovett merged 11 commits intomasterfrom
RSP-1496

Conversation

@pst67662
Copy link
Copy Markdown
Contributor

Closes

✅ Pull Request Checklist:

  • Included link to corresponding Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

🧢 Your Team:

@adobe-bot
Copy link
Copy Markdown

Build successful! 🎉

@adobe-bot
Copy link
Copy Markdown

Build successful! 🎉

@pst67662 pst67662 changed the title [WIP]RSP-1496: RadioGroup roving tabIndex RSP-1496: RadioGroup roving tabIndex Mar 30, 2020
@adobe-bot
Copy link
Copy Markdown

Build successful! 🎉

let activeChildren = React.Children.toArray(props.children).filter(child => !child.props.isDisabled);
let defaultFocusableRadio = selectedRadio || activeChildren[0] && activeChildren[0].props.value;

let [focusableRadio, setFocusableRadio] = useState(defaultFocusableRadio);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should leave it as null by default (when there's no selected radio), until one of the radios receives focus. All of the the radios would have tabIndex={0} by default. This way, if you shift tabbed into the radio group from after, the last radio would be focused instead of the first.

inputProps: {
type: 'radio',
name,
tabIndex: focusableRadio === value ? 0 : -1,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

focusableRadio === value || focusableRadio == null ? 0 : -1

@adobe-bot
Copy link
Copy Markdown

Build successful! 🎉

let {focusableProps} = useFocusable(props);
let {focusableProps} = useFocusable({
...props,
onFocus: () => setFocusableRadio(value)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would override props.onFocus. We'd need to chain them.

@adobe-bot
Copy link
Copy Markdown

Build successful! 🎉

@adobe-bot
Copy link
Copy Markdown

Build successful! 🎉

@devongovett devongovett merged commit 46403e9 into master Apr 1, 2020
@devongovett devongovett deleted the RSP-1496 branch April 1, 2020 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants