Repository navigation
Don't throw when toggling a popup or tooltip of a layer that isn't on the map - #10551
Merged
Merged
Conversation
mourner
approved these changes
Nov 9, 2026
simon04
pushed a commit
to maplair/maplair
that referenced
this pull request
Nov 9, 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.
layer.togglePopup()andlayer.toggleTooltip()throw when the layer isn't on a map, whileopenPopup()andopenTooltip()on the same layer simply do nothing:DivOverlay.toggle()calls_prepareOpen()and then opens the overlay on the source layer's map without checking the result._prepareOpen()returnsfalsewhen the layer has no map or no overlay source, andLayer.openPopup()/openTooltip()already check that return value before callingopenOn(). Without the check,toggle()passes an empty map toopenOn(), which throws. For aFeatureGroupwith no layers, which is on the map but has no source to anchor the popup to, the popup is still added to the map.toggle()now only opens the overlay when_prepareOpen()succeeds, the same wayopenPopup()andopenTooltip()do.Testing
I added specs for toggling a popup on a layer that was removed from the map, toggling a popup bound to an empty
FeatureGroup, and toggling a tooltip on a layer that was never added. All three fail onmainand pass with this change.npm test(Chromium) passes with 1396 tests, andnpm run lintandnpm run typecheckpass.