From 30d502ff637bce778ec3ec5de86e357e61f0d68a Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 14 Apr 2022 11:41:13 +0200 Subject: fix(web/ui): Fix hotkeys support in React 18 This change fixes an issue where the library for hotkeys that we previously used does not (yet) support React 18. Instead, we switch to a simpler solution based on React Hooks which is compatible with React 18. --- .../src/components/topologies/TopologyMap.js | 27 ++++++++-------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'opendc-web/opendc-web-ui/src/components/topologies/TopologyMap.js') diff --git a/opendc-web/opendc-web-ui/src/components/topologies/TopologyMap.js b/opendc-web/opendc-web-ui/src/components/topologies/TopologyMap.js index 2f27749f..47235c7e 100644 --- a/opendc-web/opendc-web-ui/src/components/topologies/TopologyMap.js +++ b/opendc-web/opendc-web-ui/src/components/topologies/TopologyMap.js @@ -20,7 +20,7 @@ * SOFTWARE. */ -import React, { useState } from 'react' +import React, { useState, useRef } from 'react' import { Bullseye, Drawer, @@ -31,8 +31,6 @@ import { Spinner, Title, } from '@patternfly/react-core' -import { configure, HotKeys } from 'react-hotkeys' -import { KeymapConfiguration } from '../../hotkeys' import MapStage from './map/MapStage' import Collapse from './map/controls/Collapse' import { useSelector } from 'react-redux' @@ -45,10 +43,7 @@ function TopologyMap() { const [isExpanded, setExpanded] = useState(true) const panelContent = setExpanded(false)} /> - // Make sure that holding down a key will generate repeated events - configure({ - ignoreRepeatedEventsWhenKeyHeldDown: false, - }) + const hotkeysRef = useRef() return topologyIsLoading ? ( @@ -60,16 +55,14 @@ function TopologyMap() { ) : ( - - - - - - setExpanded(true)} /> - - - - + + + + + setExpanded(true)} /> + + + ) } -- cgit v1.2.3