Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TagInput: Part 2 - Keyboard Navigation #3894

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

Gazook89
Copy link
Collaborator

@Gazook89 Gazook89 commented Nov 13, 2024

Description

This portion mostly focuses on improving keyboard navigation of the TagInput elements.

You should be able to tab through the Properties Editor across inputs, jumping to the "new tag" input when you hit the TagInput component. Further tabing moves you past the TagInput.

If the "new tag" input is focused, you can use the arrow keys to move back or forwards through the tags/new input, and it should trap focus inside the component when using arrow keys-- it currently does not*.

You can also tab/shift tab to move through the tags/new input, and this does not trap focus inside the component.

enter on a tag opens it for editing or submits it if currently editing, esc closes it without saving, , submits a change if editing, tab moves focus out while keeping it open for editing.

image

Related Issues or Discussions

QA Instructions, Screenshots, Recordings

Use keyboard to navigate through the TagInput and see if it's intuitive. If you want to go deeper, I'm sure this could be improved with a closer look at WCAG guidelines, though I did try to follow it pretty closely.

Reviewer Checklist

*Reviewers, refer to this list when testing features, or suggest new items *

  • Verify new features are functional
    • tab into the component from either before or after the component focuses the 'add tag' input
    • enter or , in the 'add tag' input submits a new tag
    • shift tab from 'add tag' input moves focus through tags starting from end, and escapes the component entirely from the first tag
    • tab, when focus is already inside the tag list, moves the focus through tags and escapes the component entirely from the 'add tag' input.
    • enter on a tag opens it for editing, and submits it if already open for editing
    • esc on edited tag cancels the edit and closes the input
    • , on edited tag submits it (like enter)
    • arrow keys move focus between tabs but does not escape the component when it reaches the ends
  • Verify old features have not broken
    • still saves tags to the brew as before
  • Test for edge cases / try to break things
  • Identify opportunities for simplification and refactoring
  • Check for code legibility and appropriate comments
Copy this list
- [ ] Verify new features are functional
  - [ ] `tab` into the component from either before or after the component focuses the 'add tag' input
  - [ ] `enter` or `,` in the 'add tag' input submits a new tag
  - [ ] `shift tab` from 'add tag' input moves focus through tags starting from end, and escapes the component entirely from the first tag
  - [ ] `tab`, when focus is already inside the tag list, moves the focus through tags and escapes the component entirely from the 'add tag' input.
  - [ ] `enter` on a tag opens it for editing, and submits it if already open for editing
  - [ ] `esc` on edited tag cancels the edit and closes the input
  - [ ] `,` on edited tag submits it (like `enter`)
  - [ ] `arrow keys` move focus between tabs but does not escape the component when it reaches the ends
- [ ] Verify old features have not broken
  - [ ] still saves tags to the brew as before
- [ ] Test for edge cases / try to break things
- [ ] Identify opportunities for simplification and refactoring
- [ ] Check for code legibility and appropriate comments

Removes a lot of abandoned styling, and sets a baseline for the remove buttons and the list in general.
Add a state variable for managing focus.  From prior element, tabbing into the TagInput puts the focus on the "new tag" input.  From there, shift-tabbing brings focus back through the existing tags starting from last and going to first.  From first tag, shift-tabbing moves focus to prior element outside TagInput.  Focus can be moved forward via just `tab`.

Added some styling for focus states, including a small change to the thumbnail URL button for consistency.
Add options for:

- arrow key and tab navigation,
- 'Enter' or 'Space' to edit a tag
- 'Enter', 'Tab', or ',' to submit a new tag
- 'Escape' to exit a tag without submitting
- 'Delete' to delete a tag

Tabbing from outside the component sends focus to the new tag input, from which you can shift-tab or arrowLeft to move focus through the tags.

Tabbing or shift-tabbing through the last tag or past the new tag input sends focus out of the component to wherever the next focus point is.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

Successfully merging this pull request may close these issues.

1 participant