Skip to content

Fix map field not rendering inside an inactive tab (#3097) - #3130

Merged
tabuna merged 1 commit into
orchidsoftware:masterfrom
wakqasahmed:fix/issue-3097-map-inactive-tab
Aug 26, 2026
Merged

Fix map field not rendering inside an inactive tab (#3097)#3130
tabuna merged 1 commit into
orchidsoftware:masterfrom
wakqasahmed:fix/issue-3097-map-inactive-tab

Conversation

@wakqasahmed

Copy link
Copy Markdown
Contributor

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 its shown.bs.tab listener attached to the right anchor, so invalidateSize() is never called when its own tab is activated, and Leaflet renders it at the wrong size since it was initialized while the pane was display: 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-target or href) instead of the first one on the page. If the map isn't inside a tab at all, closest returns 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 is tab-{sha1($templateSlug.$name)} and the toggle anchor carries both data-bs-target="#tab-..." and href="#tab-..." matching that id — so the new selector lines up with the existing markup.

@tabuna
tabuna merged commit 9d8c71e into orchidsoftware:master Aug 26, 2026
1 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Map field - проблема отображения в табах

2 participants