tinyMCE-mention icon indicating copy to clipboard operation
tinyMCE-mention copied to clipboard

end the lookup when typing a space

Open leoloso opened this issue 8 years ago • 4 comments

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

leoloso avatar Mar 30 '16 08:03 leoloso

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?

StevenDevooght avatar Mar 30 '16 14:03 StevenDevooght

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)

leoloso avatar Mar 30 '16 14:03 leoloso

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).

StevenDevooght avatar Mar 30 '16 15:03 StevenDevooght

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...

leoloso avatar Mar 30 '16 15:03 leoloso