Do not click on road when toggling sidebar (fixes #274)

This commit is contained in:
Paul Bienkowski 2022-09-12 17:21:28 +02:00
parent c1c3797eb8
commit 61890c6a5c
2 changed files with 29 additions and 12 deletions

View file

@ -120,7 +120,11 @@ function MapPage({ login }) {
(e) => { (e) => {
let node = e.target; let node = e.target;
while (node) { while (node) {
if (node?.classList?.contains(styles.mapInfoBox)) { if (
[styles.mapInfoBox, styles.mapToolbar].some((className) =>
node?.classList?.contains(className)
)
) {
return; return;
} }
node = node.parentNode; node = node.parentNode;
@ -162,6 +166,16 @@ function MapPage({ login }) {
layers.push(eventsTextLayer); layers.push(eventsTextLayer);
} }
const onToggleLayerSidebarButtonClick = useCallback(
(e) => {
e.stopPropagation();
e.preventDefault();
console.log("toggl;e");
setLayerSidebar((v) => !v);
},
[setLayerSidebar]
);
if (!obsMapSource) { if (!obsMapSource) {
return null; return null;
} }
@ -212,17 +226,14 @@ function MapPage({ login }) {
)} )}
<div className={styles.map}> <div className={styles.map}>
<Map viewportFromUrl onClick={onClick} hasToolbar> <Map viewportFromUrl onClick={onClick} hasToolbar>
<div className={styles.mapToolbar}>
<Button <Button
style={{
position: "absolute",
left: 16,
top: 16,
}}
primary primary
icon="bars" icon="bars"
active={layerSidebar} active={layerSidebar}
onClick={() => setLayerSidebar(layerSidebar ? false : true)} onClick={onToggleLayerSidebarButtonClick}
/> />
</div>
<Source id="obs" {...obsMapSource} tiles={tiles}> <Source id="obs" {...obsMapSource} tiles={tiles}>
{layers.map((layer) => ( {layers.map((layer) => (
<Layer key={layer.id} {...layer} /> <Layer key={layer.id} {...layer} />

View file

@ -31,3 +31,9 @@
width: 36rem; width: 36rem;
overflow: auto; overflow: auto;
} }
.mapToolbar {
position: absolute;
left: 16px;
top: 16px;
}