Skip to content

Conversation

@gaearon
Copy link
Collaborator

@gaearon gaearon commented Apr 4, 2019

Fixes #26.

I noticed search often selects a random item.

But looking closer, it was because of a partial match:

1

This changes the algorithm to also change the selection if you continue typing in the search field. I think this feels better. It also matches what Chrome does in text search more closely. (Although not quite — but implementing 1:1 mapping seems like too much complexity right now.)

2

@gaearon gaearon requested a review from bvaughn April 4, 2019 15:01
// Changes in search index should override the selected element.
if (searchIndex !== prevSearchIndex) {
// Changes in search index or typing should override the selected element.
if (searchIndex !== prevSearchIndex || searchText.indexOf(prevSearchText) === 0) {
Copy link
Owner

Choose a reason for hiding this comment

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

Nice! Yeah this makes sense.

@bvaughn bvaughn merged commit 14969c2 into bvaughn:master Apr 4, 2019
@gaearon gaearon deleted the search-fix branch April 4, 2019 15:21
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.

Searching sometimes selects root node

2 participants