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

Export SearchRef for focusing #15

Closed
wants to merge 2 commits into from

Conversation

Amerlander
Copy link
Contributor

I formerly said I could call this.focus() from outside. That was wrong and I do not know in what state my code was then that it had worked.

So this pr adds up on #11. To keep the behavior as it is it would be great for me to be able to focus from outside.

Also the select event had to be dispatched after the dropdown is closed, therefore I moved it to the end of the function.

If you dont mind I would be happy to see this code merged, otherwise I`ll just keep it for myself. :)

The only downside is, that I have to set focusAfterSelect to false to be able to actually focus after select. If I keep it to true the focus event wouldn't trigger the focus event.

@metonym
Copy link
Owner

metonym commented Feb 22, 2021

what do you want to accomplish here? give me an example and lay put the expected behavior

@Amerlander
Copy link
Contributor Author

I want to be able to select multiple items without having to refocus the input field between each selection.

I've made two Videos here: #11 (comment)
The first is the actual behavior, the second one is what I want.

@metonym
Copy link
Owner

metonym commented Feb 22, 2021

I appreciate the PR but I'm not interested in having this module emulate a multi-select filter behavior.

EDIT: I'm not opposed to exporting the searchRef though, if you find that useful.

@Amerlander
Copy link
Contributor Author

Amerlander commented Feb 23, 2021

Without dispatching the select event after setting hideDropdown to true it would not help me to have the searchRef exposed, since it will overwrite my attemptions to reopen it in the select event.

It think I just go with my forked repo and change the behaviour of focusAfterSelect to fit my expectations:

if (focusAfterSelect) {
  searchRef.focus();
} else {
  hideDropdown = true;
}

@Amerlander Amerlander closed this Feb 23, 2021
@Amerlander Amerlander deleted the focusable branch February 23, 2021 10:09
@Amerlander
Copy link
Contributor Author

Amerlander commented Feb 23, 2021

I renamed my forked repo to svelte-typeahead-multiselect, since I mostly need it as a multiselect and think it might be more clear to others. I'll still try to keep everything else in sync with your repo. I hope you are okay with that.

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