Fix map field not rendering inside an inactive tab (#3097) - #3130
Merged
tabuna merged 1 commit intoAug 26, 2026
Merged
Conversation
This was referenced Sep 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3097
The map field's Stimulus controller grabs
document.querySelector('a[data-bs-toggle="tab"]')on connect, which always returns the first tab-toggle anchor on the page regardless of which tab actually contains the map. With more than one tab (or more than one map), a map inside any tab other than the first one never gets itsshown.bs.tablistener attached to the right anchor, soinvalidateSize()is never called when its own tab is activated, and Leaflet renders it at the wrong size since it was initialized while the pane wasdisplay: none.This finds the specific tab-pane the map lives in via
closest(".tab-pane"), then looks up the toggle anchor pointing at that pane's id (data-bs-targetorhref) instead of the first one on the page. If the map isn't inside a tab at all,closestreturns null and nothing is attached, same as before.There's no existing JS test setup for the Stimulus controllers in this repo (no Jest/Vitest config, no test script in package.json), so I didn't add one. Verified the fix by tracing it against
resources/views/layouts/tabs.blade.php, where each pane's id istab-{sha1($templateSlug.$name)}and the toggle anchor carries bothdata-bs-target="#tab-..."andhref="#tab-..."matching that id — so the new selector lines up with the existing markup.