Do not click on road when toggling sidebar (fixes #274)
This commit is contained in:
parent
c1c3797eb8
commit
61890c6a5c
|
@ -120,7 +120,11 @@ function MapPage({ login }) {
|
|||
(e) => {
|
||||
let node = e.target;
|
||||
while (node) {
|
||||
if (node?.classList?.contains(styles.mapInfoBox)) {
|
||||
if (
|
||||
[styles.mapInfoBox, styles.mapToolbar].some((className) =>
|
||||
node?.classList?.contains(className)
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
node = node.parentNode;
|
||||
|
@ -162,6 +166,16 @@ function MapPage({ login }) {
|
|||
layers.push(eventsTextLayer);
|
||||
}
|
||||
|
||||
const onToggleLayerSidebarButtonClick = useCallback(
|
||||
(e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
console.log("toggl;e");
|
||||
setLayerSidebar((v) => !v);
|
||||
},
|
||||
[setLayerSidebar]
|
||||
);
|
||||
|
||||
if (!obsMapSource) {
|
||||
return null;
|
||||
}
|
||||
|
@ -212,17 +226,14 @@ function MapPage({ login }) {
|
|||
)}
|
||||
<div className={styles.map}>
|
||||
<Map viewportFromUrl onClick={onClick} hasToolbar>
|
||||
<div className={styles.mapToolbar}>
|
||||
<Button
|
||||
style={{
|
||||
position: "absolute",
|
||||
left: 16,
|
||||
top: 16,
|
||||
}}
|
||||
primary
|
||||
icon="bars"
|
||||
active={layerSidebar}
|
||||
onClick={() => setLayerSidebar(layerSidebar ? false : true)}
|
||||
onClick={onToggleLayerSidebarButtonClick}
|
||||
/>
|
||||
</div>
|
||||
<Source id="obs" {...obsMapSource} tiles={tiles}>
|
||||
{layers.map((layer) => (
|
||||
<Layer key={layer.id} {...layer} />
|
||||
|
|
|
@ -31,3 +31,9 @@
|
|||
width: 36rem;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.mapToolbar {
|
||||
position: absolute;
|
||||
left: 16px;
|
||||
top: 16px;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue