[openstreetmap/openstreetmap-website] Fix double load of the language selector (PR #7371)
Kai Michael Poppe
notifications at github.com
Tue Sep 8 12:13:06 UTC 2026
### Description
Resolves intermittent SelectLanguageTest errors.
#### Problem
Opening the language selector loaded its Turbo Frame (`#select_language_list`) twice: once when the frame became visible, and again when `shown.bs.modal` rewrote `src` to add the current `source`. Every `turbo:frame-load` resets the search field, so the second (late) load could clear a query the user had already typed and the list snapped back to all languages.
Besides the redundant request, this made `test/system/select_language_test.rb` flaky (the `"fra"` filter was wiped before the assertion).
#### Cause
- The frame auto-loaded via `src` (its `source` param baked in server-side, and stale after Turbo navigations).
- `shown.bs.modal` then set `src` again with the current `source` -> a second load, whose `turbo:frame-load` reset the search after the user could already interact.
#### Fix
Load the frame once, on `show.bs.modal` (before the dialog is interactive), with the current `source`, and only when it actually changes.
### How has this been tested?
Running the failing test in a local DEVCONTAINER a max of 30 times
```
for i in $(seq 1 30); do echo "run $i"; bin/rails test test/system/select_language_test.rb:6 || break; done
```
failed at the first the earliest or seventh the latest time. After adding to code of this PR this test ran 30 times without a problem.
You can view, comment on, or merge this pull request online at:
https://github.com/openstreetmap/openstreetmap-website/pull/7371
-- Commit Summary --
* Fix double load of the language selector
-- File Changes --
M app/assets/javascripts/application.js (18)
M app/views/layouts/_header.html.erb (2)
-- Patch Links --
https://github.com/openstreetmap/openstreetmap-website/pull/7371.patch
https://github.com/openstreetmap/openstreetmap-website/pull/7371.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/7371
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/7371 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20260908/293e9031/attachment.htm>
More information about the rails-dev
mailing list