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

fix: Autocomplete reset/re-render on keyboard events #3068

Merged
merged 1 commit into from
Apr 30, 2024

Conversation

DafyddLlyr
Copy link
Contributor

@DafyddLlyr DafyddLlyr commented Apr 29, 2024

What does this PR do?

  • Stops drop down list "resetting" to the top when an option is selected via keyboard

Context

Please see #2993 (comment)

Originally I had to nest ListboxComponent this within SelectMultiple in order to access functions related to the state of the popper.

What I think is happening is that selecting an item with they keyboard was causing a re-render of the popper and effectively resetting the view to the top of the list.

I've actually removed these here as currently clicking "Done" counts as a clickaway as it's outside of the scope of the popper (ref and props are applied to the role="listbox" child element within ListboxComponent). This actually in effect matches the current behaviour -

  • there's no custom action being triggered by "Done" (just a close)
  • it's already not keyboard navigable as a button

Before

After selecting an item, the focus shifts back to the first item
https://github.com/theopensystemslab/planx-new/assets/20502206/9f960cbf-6ff0-4007-a0fb-8597fe68f8ef

After

After selecting an item, the focus remains in place
https://github.com/theopensystemslab/planx-new/assets/20502206/6e890a66-cf08-4b43-96c4-b6bc0e78a03c

@DafyddLlyr DafyddLlyr changed the base branch from main to dp/fual-autocomplete April 29, 2024 09:23
Copy link

github-actions bot commented Apr 29, 2024

Removed vultr server and associated DNS entries

@DafyddLlyr DafyddLlyr requested a review from a team April 29, 2024 10:59
@DafyddLlyr DafyddLlyr marked this pull request as ready for review April 29, 2024 10:59
Copy link
Contributor

@ianjon3s ianjon3s left a comment

Choose a reason for hiding this comment

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

This is working perfectly as far as I can see

@DafyddLlyr DafyddLlyr merged commit 1599f68 into dp/fual-autocomplete Apr 30, 2024
12 checks passed
@DafyddLlyr DafyddLlyr deleted the dp/autocomplete-reset-on-select branch April 30, 2024 12:42
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