Repository navigation
Map picker: fit the provider list on screen and scroll it - #2460
Conversation
With several provider groups enabled, the picker's list is taller than many screens. Leaflet sizes the expanded list from the whole map's height, but the Live map runs under the nav, the replay bar and the legend, so it decided the list fit: no scrollbar, and the last entries were off screen or hidden behind the replay bar and legend. On expand, list updates and map resize, cap the list to the visible space (viewport, map bottom, and an optional bottomInset(listRect) from the caller) and turn on Leaflet's scrollbar class. Live passes the replay bar and the legend when they sit below the list.
zfouts
left a comment
There was a problem hiding this comment.
Thanks — this fixes the Live overflow, and the listener lifecycle is clean (removed on rebuild and in _detach; the collapsed early-return keeps _update storms free). It merges cleanly with #2446 and #2436, and the unit suites pass on both merged trees. A few points, most important first:
- Map/Planner: the last rows now go under the attribution bar (
map-tile-providers.js:1195). Leaflet'sexpand()caps the list atmap.getSize().y - (offsetTop + 50)._fitLayerListdrops that and re-caps at the map's bottom minus 12 px. On a phone-width Map or Planner page (picker top-left, attribution wrapping to two lines),.leaflet-bottompaints over the last row and takes its taps. That is the same symptom this PR fixes on Live, and it contradicts "Map page unchanged". Suggestion: also cap at the top of any child ofmap._controlCorners.bottomleft/bottomrightwhose rect overlaps the list's columns. That handles the attribution and any bottom control, and would also cover the ducting panel from #2436. Simpler alternative: keep Leaflet's margin when nobottomInsetis given. - Live: other bottom-right widgets aren't in the inset (
live.js:1568).#liveMapis a stacking context at z-index 1, so.legend-toggle-btn(shown when the legend is hidden),.feed-show-btn, and a feed or node detail moved to the bottom-right all paint over the capped list. Suggest including them in the selector. - A hidden legend is skipped only by geometry (
live.js:1570)..live-legend.hiddenisvisibility:hiddenplustranslateX(100%), notdisplay:none, so its rect has a height. It drops out today only because its shifted left edge sits right of the list. AgetComputedStyle(el).visibility === 'hidden'check would make that explicit. - Scroll position resets on a re-fit while open (
map-tile-providers.js:1187-1188). Clearing the height before measuring sendsscrollTopto 0 on a map resize, or on a cross-tab pin/overlay change (#2446 adds those) while the list is open and scrolled. Saving and restoringsection.scrollToparound the fit fixes it. - Very short viewports (
map-tile-providers.js:1196). Withroom <= 0the list is left uncapped, and Leaflet's cap has already been cleared, so a landscape phone with the VCR bar gets the original bug back. A floor such asMath.max(room, 60)would avoid that. - Tests. These lines can be removed without a test failing: the
_fitLayerListcall in the_updatewrapper (map-tile-providers.js:1317), the_offFitHandler()before re-registering on rebuild (map-tile-providers.js:1329), and the viewport cap. The LivebottomInsetgeometry has no test. Suggest asserting afterc._update()while expanded, checking for a single resize handler after afromConfigrebuild, and pulling the Live inset into a function of(listRect, rects, innerHeight)with its own test.
Nothing here was checked in a browser; the layout points come from the Leaflet 1.9.4 source and our CSS.
Review follow-ups: - The list also stops above the map's own bottom-corner controls in its columns (attribution, scale, any plugin), so on a phone-width Map or Planner page the last rows no longer go under the attribution. - Live's bottomInset now uses MC_layerListInset and also covers the legend toggle, the feed and its show button and a node detail. Hidden, invisible and faded-out panels are skipped explicitly. - A re-fit keeps the list's scroll position. - A very short viewport keeps a 60 px scrolling list instead of none. - Tests for the pure inset helper, the hidden-element filter, the corner controls, the viewport cap, the re-fit on _update, the scroll position, the minimum height and a single resize handler across rebuilds.
|
Thanks, Zach. All six are in
|
Summary
Follow-up to #2434. With several of the new provider groups enabled, the map picker's list is taller than many screens. On the Live page it gets no scrollbar, and the last entries end up off screen or behind the replay bar and the legend.
Cause
Leaflet's layer control sizes the expanded list from the whole map's height (
map.getSize().yminus the control's offset). On the Live page the map fills the window and runs under the nav, the replay bar and the legend, so Leaflet decides the list fits when the visible part of the map is much shorter. The Map page is not affected in practice, because its map ends where the visible area ends.Fix
map-tile-providers.js:_fitLayerListcaps the expanded list to the visible space and turns on Leaflet's ownleaflet-control-layers-scrollbarclass when the list doesn't fit. The limit is the lowest of:bottomInset(listRect)from the caller.It runs on expand, when the list is re-rendered, and on map
resize. The resize handler is removed with the control.MC_attachAutoTiles(map, { controlPosition, bottomInset }): the new option is passed through to the picker. Callers that don't pass it behave as before, apart from the viewport and map-edge cap.live.js: passes abottomInsetthat covers#vcrBarand.live-legendwhen either sits below the list in its columns.Testing
tests/unit/test-map-layer-builder.js. It checks that:test-all.shandnpx eslint public/*.jspass.