Skip to content

Conversation

@ilyabo
Copy link
Collaborator

@ilyabo ilyabo commented Jan 7, 2026

Before the fix the legend wouldn't react to changes in the map container height. After fix it does:

Kapture.2026-01-07.at.15.21.17.mp4

The demo app still works too:

Kapture.2026-01-07.at.15.24.40.mp4

ilyabo added 2 commits January 7, 2026 15:14
Signed-off-by: Ilya Boyandin <ilyabo@gmail.com>
Signed-off-by: Ilya Boyandin <ilyabo@gmail.com>
Copilot AI review requested due to automatic review settings January 7, 2026 14:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements functionality to clamp the legend height when it exceeds the available space in the map viewport. The fix ensures the legend panel remains fully visible within the map boundaries by calculating a maximum content height based on map dimensions and clamping the legend's contentHeight accordingly.

Key changes:

  • Added maxContentHeight calculation based on map dimensions in the useLegendPosition hook
  • Implemented automatic clamping of legend content height when it exceeds available space
  • Added test coverage for the new maxContentHeight calculation and clamping behavior

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
test/browser/components/hooks/use-legend-position.spec.js Added three new test cases to verify maxContentHeight calculation and contentHeight clamping behavior
src/components/src/hooks/use-legend-position.ts Added maxContentHeight calculation, useEffect to clamp contentHeight when map resizes, and updated parameters to accept mapHeight/mapWidth
src/components/src/map/map-legend-panel.tsx Updated component to pass mapState dimensions to the hook and thread maxContentHeight prop through to styled components

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Ilya Boyandin <ilyabo@gmail.com>
@ilyabo ilyabo requested a review from igorDykhta January 7, 2026 14:52
? Math.min(
maxContentHeight,
mapRootBounds.bottom -
(legendRect.top + MAP_CONTROL_HEADER_FULL_HEIGHT + MARGIN.bottom)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to a separate variable

mapRootBounds.bottom -
                (legendRect.top + MAP_CONTROL_HEADER_FULL_HEIGHT + MARGIN.bottom)

Signed-off-by: Ilya Boyandin <ilyabo@gmail.com>
@ilyabo ilyabo merged commit 2ba9f6e into master Jan 9, 2026
9 checks passed
@ilyabo ilyabo deleted the fix--Clamp-legend-height-if-it-exceeds-available-space branch January 9, 2026 11:15
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.

3 participants