BUG: File tagging stacks, breaks textbox

Reporting this again because it’s still happening after seven months. :\

BUG: If you tag a file and then (after that tag goes through) immediately attempt to type another tag, the text you enter into the textbox may be erased repeatedly as you type. This bug always happens under certain conditions.

HOW TO REPRODUCE: Do a File search for anything that will return at least one file.

Click a file’s thumbnail to go into Details View on that file. Then, click outside of Details View to close it. Repeat this step exactly ten more times. Do not attempt to interact with any of these files (tagging, Liking, etc.).

If your browser has a debugging tool that lets you view AJAX requests, open it now.

Open a file’s Details View again. Clear any output in your debugging tool. Attempt to apply a tag to this file. The moment the tag is successfully applied, attempt to type another tag, as if you were going to apply it.

TIP FOR MOUSE USERS: Use your keyboard to perform these steps more quickly and bring out the bug. TAB from the tag textbox to the “Tag” button and hit Enter to apply the tag. when the textbox reappears, SHIFT+TAB back to it and start typing immediately.

You should see the text that you’re trying to type get deleted as you type it. If you have a debugger open, you should also see that twelve AJAX requests were sent just for the one tag that you applied, and that the text you’ve been typing into the textbox is being cleared every time one of those requests completes. That’s one AJAX request for every time you opened any file’s Details View.

EXPLANATION: Every time you go into Details View on a file, a new copy of the JavaScript event handler for the “Tag” button is attached to that button.

The first time you open a file’s details, things work fine. You can apply as many tags as you want, and everything will work normally.

The second time you open a file’s details, you will send two AJAX requests every time you apply one tag. Each time one of those requests completes, the contents of the textbox for tagging are wiped, interfering with typing.

The third time you open a file’s details, you will send three AJAX requests every time you apply one tag, making this bug occur. Again, the textbox will be wiped with each completed AJAX request, interfering with typing.

The problem continues and gets worse every time you open the “fancybox” on a file, eventually building to the point where you won’t be able to type in any tags at all for several seconds after applying a tag to a file.

ADVICE ON FIXING: Modify the JavaScript function that gets stored at UGC.Tags.init to either use a run-once flag, or replace all references to itself with an empty function after it does what it needs to do.

I wrote a userscript to apply the fix as a monkeypatch, and the issue is completely gone when the userscript runs.

May as well report this other File Browser bug as well.

BUG: There are no provisions in place – not even so much as a “Retry” button – to account for the File Browser’s AJAX failing. If the AJAX request for files returns an Error 500 while on someone’s File Share or Recent Screenshots, no error message is ever displayed; the loading animation plays infinitely, and you’ll only know for sure that it’s broken (as opposed to just lagging) if you happen to have developer tools running.

Setup: Firefox 24.

And here’s another one.

BUG: Under certain circumstances, applying tags to files via the web UI is broken. Specifically, if I access a file directly (like this) instead of through a search, then the “Add Tag” button does not function at all. Tagging files on a search page works.

To be clear, I cannot go directly to a file, type in a tag, and click “Add Tag”. All that happens is that the browser jumps to the top of the page without sending any AJAX requests (click event handler on the button doesn’t trigger). However, I can whip out my Web Console, call UGC.Tags.submit(“my tag”) and that works perfectly, even displaying the added tag in the UI.

Setup: Firefox 24.

> And here’s another one.
>
> BUG: Under certain circumstances, applying tags to files via the web UI is broken. Specifically, if I access a file directly (like this) instead of through a search, then the “Add Tag” button does not function at all. Tagging files on a search page works.
>
> To be clear, I cannot go directly to a file, type in a tag, and click “Add Tag”. All that happens is that the browser jumps to the top of the page without sending any AJAX requests (click event handler on the button doesn’t trigger). However, I can whip out my Web Console, call UGC.Tags.submit(“my tag”) and that works perfectly, even displaying the added tag in the UI.
>
> Setup: Firefox 24.

Have you been able to attempt this in a different browser? I was able to use that link and apply a tag without issue on IE.

> BUG: If you tag a file and then (after that tag goes through) immediately attempt to type another tag, the text you enter into the textbox may be erased repeatedly as you type. This bug always happens under certain conditions.

Tried adding a tag directly after the first one, was unable to get these results as well.

> Have you been able to attempt this in a different browser? I was able to use that link and apply a tag without issue on IE.

Just tested on Firefox. Seems to work now. How odd.

> > BUG: If you tag a file and then (after that tag goes through) immediately attempt to type another tag, the text you enter into the textbox may be erased repeatedly as you type. This bug always happens under certain conditions.
>
> Tried adding a tag directly after the first one, was unable to get these results as well.

On Firefox, I am able to get the bug to occur intermittently after the sixth file (on a single pageload) that I fullview. I can also reproduce it on Chrome, though browser quirks make it a bit trickier.

I can send two screen recordings of the bug by e-mail if you’d like:
Firefox, ninth file opened in one pageview, 11.6MB AVI
Chrome, tenth-or-so file opened in one pageview, 8.08MB AVI

(Remember when attempting to repro: you need to be on a page with multiple files, and the bug will only become apparent after full-viewing multiple files during a single pageview. The more files you’ve fullviewed, the more apparent the bug comes – and the more likely it is to make you apply half a tag by accident.)