Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
AO3-4004 Handle focus after autocomplete token limit reached #2656
Conversation
sarken
added
the
Awaiting review
label
Dec 16, 2016
| @@ -534,6 +535,8 @@ $.TokenList = function (input, url_or_data, settings) { | ||
| // Check the token limit | ||
| if(settings.tokenLimit !== null && token_count >= settings.tokenLimit) { | ||
| + // move focus to the remove option of the last token and then hide the input |
sarken
added some commits
Dec 16, 2016
|
I worry a bit about adding custom code to a plugin that isn't by us. But the code itself is good. And the jQuery selectors for the external work bookmarking form all worked when I tried them out. Since this is a useful fix, you could submit it as a pull request on the plugin's github? |
|
I'm not overly fond of the approach either, but it's unfortunately very heavily customized at this point -- I once thought it would be nice to update it, but we've already rewritten so much of it, it was pretty much impossible. So this is unfortunately in line with what we've been doing, and also not applicable to the original plugin's code. |
|
Also, ugh, those other files were not supposed to be in here. Let me get them out... |
|
Oh, I wasn't aware that it was already customized. Since you say the reason why I didn't like it has already occurred, I have no issue with further customization. :D |
|
Yay, thanks! Can you switch the label to ready to merge? |
sarken commentedDec 16, 2016
•
Edited 1 time
-
sarken
Dec 16, 2016
Issue
https://otwarchive.atlassian.net/browse/AO3-4004
Purpose
When an autocomplete field has a limit to how many items you can enter in it (e.g. the Synonym field on tag Edit pages limits you to entering 1 synonym), keyboard focus would behave oddly after you reached that limit. In some browsers, it would stay on the now-hidden input, so you couldn't see where it was, which was mildly annoying. In other browsers, it would just freak out and go away, and you'd start back at the top of the page -- super annoying if you're halfway through filling out a form.
So! Now we put the focus on the little × that lets you remove the last item you entered. You can then either hit enter to remove the item and type a new one, or hit tab to move to the next item in the form.
References
Believe it or not, this is related to tests! james_ was trying to improve test coverage for the external_works controller, so he removed something that was broken, and I said, "hey, let's fix it instead -- it's easy!" Which was a foolish thing to say and I should know better. When I fixed that bug and tried to write a test using our exciting new ability to test things with JavaScript, this bug got in my way. So here we are.
And it helps to know that this is the HTML you get when you have an autocomplete and two tokens: