fix: Clamp legend height if it exceeds available space - #3276
Merged
ilyabo merged 4 commits intoJan 9, 2026
Conversation
Signed-off-by: Ilya Boyandin <ilyabo@gmail.com>
Contributor
There was a problem hiding this comment.
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
maxContentHeightcalculation based on map dimensions in theuseLegendPositionhook - 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.
igorDykhta
approved these changes
Jan 7, 2026
| ? Math.min( | ||
| maxContentHeight, | ||
| mapRootBounds.bottom - | ||
| (legendRect.top + MAP_CONTROL_HEADER_FULL_HEIGHT + MARGIN.bottom) |
Collaborator
There was a problem hiding this comment.
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
deleted the
fix--Clamp-legend-height-if-it-exceeds-available-space
branch
January 9, 2026 11:15
bdjulbic
pushed a commit
to bdjulbic/kepler.gl
that referenced
this pull request
Jan 30, 2026
* fix: Clamp legend height if it exceeds available space Signed-off-by: Ilya Boyandin <ilyabo@gmail.com> * simplify Signed-off-by: Ilya Boyandin <ilyabo@gmail.com> * fixes Signed-off-by: Ilya Boyandin <ilyabo@gmail.com> * PR feedback Signed-off-by: Ilya Boyandin <ilyabo@gmail.com> --------- Signed-off-by: Ilya Boyandin <ilyabo@gmail.com> Signed-off-by: bdjulbic <bdjulbic@foursquare.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.
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