Fix wrong z-index after toggling path visibility#5
Open
usero-agent[bot] wants to merge 1 commit into
Open
Conversation
Toggle path layer visibility instead of removing and re-adding layers. Previously, pressing and releasing 'h' would remove path layers from the map and re-add them, which caused OpenLayers to place the re-added layers on top of the layer stack, breaking z-index ordering. The selected path (zIndex 2) would render above the path detail colored segments (zIndex 3). Now uses layer.setVisible() to toggle visibility, which preserves the layers in the map's layer collection and maintains correct z-index ordering. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
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.
Summary
hkeylayer.setVisible()APIsetPathLayersVisible()helper function and separated the visibility toggle into its ownuseEffectRoot Cause
When pressing and releasing the
hkey, the path layers (unselected paths, selected path, access network) were being removed from the map and then re-added viamap.addLayer(). In OpenLayers, re-adding layers places them at the end of the layer collection, which can break z-index ordering. This caused the selected path layer (zIndex 2, blue baseline) to render on top of the path detail colored segments layer (zIndex 3), making the colored segments invisible beneath the blue path.Fix
Instead of removing and re-adding layers to toggle visibility, the fix uses
layer.setVisible(false/true). This keeps the layers in the map's layer collection, preserving their z-index ordering. The layer creation/update logic (which handles data changes like path selection) remains separate from the visibility toggle logic.Test plan
npx tsc --noEmit)npm test)hto toggle path visibilityFixes #4
Generated by Usero via Claude Code.
View feedback →