Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This causes weird UX:
- In firefox for example, after each pause in typing inside the filter field the search-as-you-type feature fires up and focus switches to the browser search box. One needs to click inside the filter field again and again in order to continue filtering the list of files.
- Hitting the backspace takes you to the previous page. This forces people to re-edit and re-click the link that launches the "Select a file" dialog. A lot more clicks for the user to get back to they were.
Comment | File | Size | Author |
---|---|---|---|
#5 | media-exposed_field_focus-2084287-5.patch | 2.29 KB | emacoti |
#3 | media-exposed_field_focus-2084287-3.patch | 2.35 KB | emacoti |
#2 | media-file-name-focus-2084287-2.patch | 1000 bytes | dsnopek |
Comments
Comment #0.0
klonos...one more example glitch
Comment #1
dsnopekThis appears to be the result of an issue in Views (since this is just using the 'autosubmit' feature of Views): #1217948: exposed filter with autosubmit and ajax loses keyboard focus
It doesn't appear like that issue is anywhere near consensus on how to solve it, so working around it in Media is probably the most viable approach. Simply setting the focus back to the input after auto submit has been triggered seems like the easiest approach...
Comment #2
dsnopekHere's a patch that works in my testing! Please let me know what you think.
We'll likely start using this in Panopoly soon-ish.
Comment #3
emacoti CreditAttribution: emacoti as a volunteer commentedI tried the patch and it solved the issue with the lost focus. But, after more testing was done, I found another issue which is related to timing and the auto-submit provided for ctools.
The test to reproduce was: I just type some characters and wait until the ajax request starts. Then, when the request is almost done its processing, I just type a character again and this starts the auto-submit functionality, but javascript functionality, that one that handle the form submit doing an ajax call instead of the regular form submit, its not in place so the submit perform a submit over the action form param ("/") and it breaks the library view leaving us without the functionality and needing to reload the page.
So, I made a fix for this based on the previous patch and adding some functionality that forces the browser to lose the focus and prevent user event keys. Once the Ajax request is finished, we return the focus to the field. This way, the user can't brake the library anymore and he still recover his selected field focus after ajax was done.
I made several tests and it works as expected. Any feedback welcomed.
Comment #5
emacoti CreditAttribution: emacoti as a volunteer commentedThe same patch with the right version of the media module for this issue.
Comment #6
emacoti CreditAttribution: emacoti as a volunteer commentedComment #8
joseph.olstadfixed in 7.x-2.x dev branch