- Issue created by @bkosborne
@bkosborne What browser did you test in?
For me testing locally on latest 11.x dev:
- drush si standard -y
- drush en media_library
- Add image media field to basic page
- Create basic page, upload media image, save
- Edit basic page
- Remove selected media
On Windows, Chrome 131.0.6778.205, when I reload, the media selection is restored on the page. When I click the remove button again, the media item is correctly removed.
Also on Windows, Firefox 133.0.3, I can reproduce the issue mentioned in the IS. However, if I revisit the page (while on the page, click in location bar and hit enter) instead of reloading, then the remove button works as expected.
It seems to be related to Firefox keeping form data on reload: https://stackoverflow.com/questions/7377301/firefox-keeps-form-data-on-r.... It's an old issue on stackoverflow, but I can confirm that if I add the
autocomplete="off"
attribute to the node form, e.g.$form['#attributes']['autocomplete'] = 'off';
, then reloading on Firefox works the same as Chrome.- Merge request !10706Issue #3495881: Prevent browsers from retaining form build ID value. β (Closed) created by godotislate
FWIW, making sure the form_build_id hidden input value does not get retained by the browser was enough to fix the issue for me on Firefox. I put up a draft MR 10706 with that change.
- πΊπΈUnited States bkosborne New Jersey, USA
It didn't occur to me to test in Chrome, thanks for that! I guess due the nature of the issue I didn't think it would be browser specific. Thanks for doing that and the MR! I'll test this next week and report back...
@bkosborne I tested this issue on my local environment, and I can confirm that the behavior is browser-specific and occurs only in Mozilla Firefox (133.0.3).
In Firefox, the issue described in the IS is reproducible. Specifically, after removing the media and reloading the page, the previously selected media reappears. Interestingly, if the page is manually reloaded by revisiting the URL (clicking the location bar and pressing Enter), the "remove" button works as expected.
This behavior seems to be linked to Firefox's form data persistence on reload, as outlined in the StackOverflow thread: Firefox Keeps Form Data on Reload. Adding autocomplete="off" to the node form resolves the issue on Firefox and ensures consistent behavior across browsers.
Iβve reviewed the proposed changes in the MR,. This MR looks good to move forward. Let me know if additional testing is needed!
- πΊπΈUnited States bkosborne New Jersey, USA
Okay, confirmed that setting form_build_id autocomplete to off resolves the issue for me!
I don't know how a test can be created for this, given it only affects firefox
- π¬π§United Kingdom catch
While we can't add firefox testing yet, should we add an assertion in an existing test somewhere that the form build ID has the attribute? Maybe with a @todo pointing to π Add ability to test on Firefox using selenium Postponed ?
- π¬π§United Kingdom catch
Since this was previously RTBC before the test coverage was added, going to go ahead and commit.
Committed/pushed to 11.x, cherry-picked to 11.1.x, 10.5.x, and 10.4.x, thanks!
Automatically closed - issue fixed for 2 weeks with no activity.