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

end the lookup when typing a space #36

Open
leoloso opened this issue Mar 30, 2016 · 4 comments
Open

end the lookup when typing a space #36

leoloso opened this issue Mar 30, 2016 · 4 comments

Comments

@leoloso
Copy link

leoloso commented Mar 30, 2016

Hi Steven, thanks for your plug-in, I'm using it to allow users input @mentions and #hashtags. I will suggest a new functionality to make it work smoother for #hashtags.

Right now, when typing # then a keyword and then a space (without ever having selected a value from the dropdown), it is still considered part of the keyword and it continues the lookup. However, when implementing the '#' lookup for Twitter-like hashtags, the user will most likely type in the whole keyword without selecting it from the dropdown. For these, the space should act as a delimiter, upon which the lookup is ended, and a new one will start upon typing '#' (eg: as typing #these #are #many #hashtags).

Thanks,
Leo

@StevenDevooght
Copy link
Owner

Hi leoloso, so if I understand this correctly when the user types the complete hashtag there will be only one value left in the dropdown to choose from. Hitting the space in that case should select that value?

@leoloso
Copy link
Author

leoloso commented Mar 30, 2016

Hi Steven,

no, if the lookup has no items, then the dropdown will already have disappeared, however it never gets cleared (it keeps trying to look for a match for each character you type in, including the space)

So then, if you type #first #second #third, and let's say you never selected any option from the first dropdown, then it doesn't even try to list elements when typing #second or #third, since the plugin is still engaged looking for elements for #first...

Actually, if you click on the space, nothing happens since the code for the space (32) is not handled... so even if you click the down arrow key to select the item, and then click on space, the element does not get selected but the space is added to the lookup keyword. That, you can't see it just after clicking the space, since you're doing trim() to the value, however the next character you'll see it. In this case, the lookup term will be "first s" then "first se" then "first sec" and so on)

@StevenDevooght
Copy link
Owner

Ah ok, hitting the space should just cancel the lookup and submit the value just as you would hit ESC or ENTER. I think this behavior makes sense (Only if the lookup doesn't return any matches).

@leoloso
Copy link
Author

leoloso commented Mar 30, 2016

Agree, however I think that sometimes (mostly for Twitter-like hashtags) it makes sense to treat the space as a delimiter to end the lookup always, even if the lookup was not empty. Eg: if you have item #crossover in your dropdown, but the user types #cross and then space, then that's a new keyword, completely different than #crossover...

So maybe you can add some extra configuration for each delimiter, asking if they accept spaces or not...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants