9e4f79d1e5
* Fix(#5328): Layers Control scrollable even if collapsed: false the `expand()` method was called only when expanding the Layers Control through user action. In the case of option `collapsed: false`, no event listener is attached (no user action expected to expand), therefore the control height is no longer adjusted compared to map container's height, whereas the only time it is done is at initialization, when the control is not yet inserted into the DOM, hence it does not have an actual height to check against. Therefore added a hook on `addTo()` in order to run `expand()` AFTER the control has been insterted into the DOM. The same issue happens when later adding more base layers / overlays to the Layers Control: it not collapsed, we should run again the height check (e.g. through the `expand()` method) to make sure we make it scrollable if necessary. Therefore called `expand()` after each `_addLayer()`. Actually checking first if the control is on map and if option `collapsed: false` in order to prevent calling `expand()` for nothing. * Test(ControlLayers): 2 tests for collapsed: false being scrollable (for issue #5328). CAUTION: unlike most other tests, had to actually insert the map container into the DOM (i.e. `document.body`) for these tests to be useful, otherwise the height remains at 0. This may lead to memory leak and tests hanging if done on too many tests (see Leaflet.markercluster tests issue, e.g. https://github.com/Leaflet/Leaflet.markercluster/pull/577) |
||
---|---|---|
.. | ||
Control.AttributionSpec.js | ||
Control.LayersSpec.js | ||
Control.ScaleSpec.js | ||
ControlSpec.js |