diff --git a/src/components/map/Map.tsx b/src/components/map/Map.tsx index 53676feaa..05d2b1d6b 100644 --- a/src/components/map/Map.tsx +++ b/src/components/map/Map.tsx @@ -30,8 +30,9 @@ import MapLayersControl from './mapControls/MapLayersControl'; import MapLayersZoomHint from './mapControls/MapLayersZoomHint'; import MeasurementControl from './mapControls/MeasurementControl'; import Toolbar from './toolbar/Toolbar'; +import { RouteComponentProps, withRouter } from 'react-router'; -interface IMapProps { +interface IMapProps extends RouteComponentProps { mapStore?: MapStore; routeListStore?: RouteListStore; nodeStore?: NodeStore; @@ -197,7 +198,7 @@ class LeafletMap extends React.Component {
- +
@@ -225,6 +226,5 @@ class LeafletMap extends React.Component { } } -export default LeafletMap; - +export default withRouter(LeafletMap); export { LeafletContext }; diff --git a/src/components/map/layers/edit/EditLinkLayer.tsx b/src/components/map/layers/edit/EditLinkLayer.tsx index 681ff225e..d09e8d954 100644 --- a/src/components/map/layers/edit/EditLinkLayer.tsx +++ b/src/components/map/layers/edit/EditLinkLayer.tsx @@ -109,12 +109,23 @@ const EditLinkLayer = inject( const coordsToDisable = [coords[0], coords[coords.length - 1]]; coordsToDisable.forEach((coordToDisable: any) => { const vertexMarker = coordToDisable.__vertex; - vertexMarker.dragging.disable(); - vertexMarker._events.click = {}; - vertexMarker.setOpacity(0); + + if (!vertexMarker) return; + + if (vertexMarker.dragging) { + vertexMarker.dragging.disable(); + } + + if (vertexMarker.off) { + vertexMarker.off('click'); + } else if (vertexMarker._events) { + vertexMarker._events.click = {}; + } + + vertexMarker.setOpacity?.(0); // Put vertex marker z-index low so that it // would be below other layers that needs to be clickable - vertexMarker.setZIndexOffset(-1000); + vertexMarker.setZIndexOffset?.(-1000); }); } setSelectedLinks([selectedLink]); diff --git a/src/components/map/toolbar/Toolbar.tsx b/src/components/map/toolbar/Toolbar.tsx index 02e4213ed..0551b83c8 100644 --- a/src/components/map/toolbar/Toolbar.tsx +++ b/src/components/map/toolbar/Toolbar.tsx @@ -1,7 +1,6 @@ import { observer } from 'mobx-react'; import React from 'react'; import { matchPath } from 'react-router'; -import navigator from '~/routing/navigator'; import SubSites from '~/routing/subSites'; import LoginStore from '~/stores/loginStore'; import ToolbarCommonButtons from './ToolbarCommonButtons'; @@ -11,17 +10,23 @@ import LinkButtons from './toolbarLinkButtons'; import RoutePathButtons from './toolbarRoutePathButtons'; import UndoButtons from './undoButtons'; +interface IToolbarProps { + pathname: string; +} + @observer -class Toolbar extends React.Component { +class Toolbar extends React.Component { private renderViewSpecificTools = () => { if (!LoginStore!.hasWriteAccess) return null; - if (matchPath(navigator.getPathName(), SubSites.routePath)) { + const pathname = this.props.pathname; + console.log(pathname); + if (matchPath(pathname, SubSites.routePath)) { return this.renderToolbarBlock([, ]); } - if (matchPath(navigator.getPathName(), SubSites.link)) { + if (matchPath(pathname, SubSites.link)) { return this.renderToolbarBlock([, ]); } - if (matchPath(navigator.getPathName(), SubSites.node)) { + if (matchPath(pathname, SubSites.node)) { return this.renderToolbarBlock([]); } return null; diff --git a/src/components/map/toolbar/ToolbarCommonButtons.tsx b/src/components/map/toolbar/ToolbarCommonButtons.tsx index bb1c072d5..1395e21fd 100644 --- a/src/components/map/toolbar/ToolbarCommonButtons.tsx +++ b/src/components/map/toolbar/ToolbarCommonButtons.tsx @@ -25,6 +25,7 @@ class ToolbarCommonButtons extends React.Component { }; render() { + console.log(this.props.hasWriteAccess); return ( <> {this.props.hasWriteAccess && ( diff --git a/src/components/sidebar/routePathView/routePathListTab/RoutePathLinksTab.tsx b/src/components/sidebar/routePathView/routePathListTab/RoutePathLinksTab.tsx index 7fe8dd7a3..a8bc498eb 100644 --- a/src/components/sidebar/routePathView/routePathListTab/RoutePathLinksTab.tsx +++ b/src/components/sidebar/routePathView/routePathListTab/RoutePathLinksTab.tsx @@ -74,16 +74,18 @@ class RoutePathLinksTab extends React.Component { }; private scrollIntoListItem = (listItemId: string) => { - // Next tick is needed because this way the possible previously opened item gets closed before the next one gets opened - process.nextTick(() => { - const item = this.listObjectReferences[listItemId]; - if (item && item.current) { - item.current.scrollIntoView({ - inline: 'start', - block: 'start', - behavior: 'smooth', - }); - } + window.requestAnimationFrame(() => { + window.requestAnimationFrame(() => { + const item = this.listObjectReferences[listItemId]; + + if (item && item.current) { + item.current.scrollIntoView({ + inline: 'start', + block: 'start', + behavior: 'smooth', + }); + } + }); }); };