fix: do not show "back to home" button in iframes (#2644)

This commit is contained in:
David Larlet 2025-04-14 10:21:21 -04:00 committed by GitHub
commit 82dcd90405
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 1 deletions

View file

@ -108,7 +108,7 @@ export default class Umap {
// Do not display in an iframe.
if (window.self !== window.top) {
geojson.properties.homeControl = false
this.properties.homeControl = false
}
this._leafletMap.setup()

View file

@ -0,0 +1,25 @@
from playwright.sync_api import expect
def test_home_control_is_hidden(live_server, map, tilelayer, page):
body = f"""
<html>
<head></head>
<body>
<iframe width="100%" height="300px" frameborder="0" allowfullscreen allow="geolocation"
src="{map.get_absolute_url()}?scaleControl=false&miniMap=false&scrollWheelZoom=false&zoomControl=true&editMode=disabled&moreControl=true&searchControl=null&tilelayersControl=null&embedControl=null&datalayersControl=true&onLoadPanel=caption&captionBar=false&captionMenus=true"></iframe>
</body>
</html>
"""
def handle(route):
route.fulfill(body=body)
url = f"{live_server.url}/test-iframe"
# Intercept the route
page.route(url, handle)
page.goto(url)
expect(
page.locator("iframe").content_frame.get_by_role("link", name="Home logo")
).to_be_hidden()