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

Pro 4440 - accessible/keyboard-able relationship field autocompletes #4728

Merged

Conversation

stuartromanek
Copy link
Member

Summary

https://linear.app/apostrophecms/issue/PRO-4440/%5Baccessibility%5D-make-relationship-field-suggestions-accessible

  • Adds relevant aria tags for combo list
  • Adds keyboard controls for making selections via the autocomplete suggestion list

What are the specific steps to test this change?

relationshjip.mp4
  • When you first focus the relationship search input, the suggestion list should appear
  • You should be able to navigate the suggestions with Up and Down arrow keys
  • You should be able to select a suggestion with Enter key
  • The suggestion list can be hidden with Escape
  • If the suggestion list is hidden and the input is focused, you can bring the suggestion list back up with Down or Up arrow keys

What kind of change does this PR introduce?

(Check at least one)

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Build-related changes
  • Other

Make sure the PR fulfills these requirements:

  • It includes a) the existing issue ID being resolved, b) a convincing reason for adding this feature, or c) a clear description of the bug it resolves
  • The changelog is updated
  • Related documentation has been updated
  • Related tests have been updated

If adding a new feature without an already open issue, it's best to open a feature request issue first and wait for approval before working on it.

Other information:

Copy link

linear bot commented Sep 16, 2024

Comment on lines +191 to +192
this.searchSuggestion = !qs.autocomplete && this.suggestion;
this.searchHint = (!qs.autocomplete || !results.length) && this.hint;
Copy link
Member Author

Choose a reason for hiding this comment

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

The Suggestion and Hint UI objects were originally part of the list of results. I separated these out so that I could cleanly pseudo focus search suggestions by index and not have to worry about accounting for the fake UI 'results'

Comment on lines +242 to +243
this.handleFocusOut();
this.input();
Copy link
Member Author

Choose a reason for hiding this comment

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

Flash UI to remove select element from list

Comment on lines +228 to +230
if (!this.searchList.length) {
this.input();
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Trigger suggestions if they are hidden

Comment on lines +236 to +238
if (!this.searchList.length) {
this.input();
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Trigger suggestions if they are hidden

@stuartromanek
Copy link
Member Author

This field needs to be updated with a more traditional multi-select combo box UI rather than appending the slats underneath, it makes for an awkward structure when making multiple selections
https://codepen.io/ryanjgill/pen/Dgbwab

if (this.searchList.length) {
// psuedo focus first element
this.searchFocusIndex = 0;
}
},
handleFocusOut() {
// hide search list when click outside the input
// timeout to execute "@select" method before
setTimeout(() => {
this.searchList = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

should we reset this.searchSuggestion and this.searchHint too?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think its necessary .. those props are refreshed every search and the UI is closed every selection (when it is reopened search is run again), so I don't think the get out of sync

stuartromanek and others added 3 commits October 22, 2024 15:14
…etes' of github.com:apostrophecms/apostrophe into pro-4440/accessible-keyboardable-relationship-autocompletes
@stuartromanek
Copy link
Member Author

@stuartromanek stuartromanek merged commit 240f642 into main Oct 28, 2024
8 checks passed
@stuartromanek stuartromanek deleted the pro-4440/accessible-keyboardable-relationship-autocompletes branch October 28, 2024 15:34
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.

2 participants