Fix autocomplete keyboard nav in link popover#10716
Merged
Conversation
noisysocks
approved these changes
Oct 18, 2018
Member
noisysocks
left a comment
There was a problem hiding this comment.
Thanks for staying on top of this and for getting a fix up so fast! 🙌
This fixes the bug for me locally and I'm not seeing any regressions. Glad that our war chest of link E2E tests is getting a little bit bigger with each passing day.
One thing I just noticed is that there's an inconsistency between using the keyboard and using the mouse. When you use the keyboard, the link is immediately inserted and you are no longer in link edit mode. When you use the mouse, the URL is inserted but you remain in link edit mode.
Would be good to address that, but I don't think it's a blocker.
| if ( showSuggestions && selectedSuggestion !== null && ! this.scrollingIntoView ) { | ||
| this.scrollingIntoView = true; | ||
| scrollIntoView( this.suggestionNodes[ selectedSuggestion ], this.autocompleteRef, { | ||
| scrollIntoView( this.suggestionNodes[ selectedSuggestion ], this.autocompleteRef.current, { |
Member
|
Let's get it in as it's better than what we had before. We have whole RC cycle to improve it :) |
antpb
pushed a commit
to antpb/gutenberg
that referenced
this pull request
Oct 26, 2018
* Fix autocomplete cursor key navigation * Avoid running onClickOutside logic for other non-onClickOutside events * Add e2e tests for keyboard interaction with link container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #10689
Resolves a regression caused by #10500:
Fix adding links from the autocompleter #10500 changed the type of ref in the URLInput to a
createRef. To access the underlying element with a createRef,ref.currentmust be used, but an instance of this was missed in that change, causingscrollIntoViewto throw an error:https://github.com/WordPress/gutenberg/compare/fix/autocomplete-keyboard-nav-in-link?expand=1#diff-95b4cd296d28092a0710c1d98aee45d8R49
On further testing, there was also an issue with using the escape key not closing the url input. This was caused by
eventbeing undefined in theresetStatemethod when called from a couple of callsites. The fix for this was to extract a separate onClickOutside handler:https://github.com/WordPress/gutenberg/compare/fix/autocomplete-keyboard-nav-in-link?expand=1#diff-3fc799f44a8120d79cc3867b1d703822R179
How has this been tested?
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: