Skip to content

Fix wrong z-index after toggling path visibility#5

Open
usero-agent[bot] wants to merge 1 commit into
masterfrom
usero/1772770861376-cmmedzpx4000j190euygm24vw
Open

Fix wrong z-index after toggling path visibility#5
usero-agent[bot] wants to merge 1 commit into
masterfrom
usero/1772770861376-cmmedzpx4000j190euygm24vw

Conversation

@usero-agent

@usero-agent usero-agent Bot commented Mar 6, 2026

Copy link
Copy Markdown

Summary

  • Fixed z-index ordering breaking after toggling path visibility with the h key
  • Changed the visibility toggle mechanism from removing/re-adding layers to using OpenLayers' layer.setVisible() API
  • Added a setPathLayersVisible() helper function and separated the visibility toggle into its own useEffect

Root Cause

When pressing and releasing the h key, the path layers (unselected paths, selected path, access network) were being removed from the map and then re-added via map.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

  • TypeScript compilation passes (npx tsc --noEmit)
  • All 66 existing tests pass (npm test)
  • Manual: Select a route with path details visible (colored segments on the path)
  • Manual: Press and release h to toggle path visibility
  • Manual: Verify colored segments remain visible on top of the blue baseline after toggling

Fixes #4


Generated by Usero via Claude Code.
View feedback →

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong z-index after toggling path visibility

0 participants