From 66330485b17c3ffe3f8eda962c1e016e8632e1ff Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Wed, 6 Apr 2022 14:28:07 +0300 Subject: [PATCH] Fix broken hotbar switcher (#5182) * Getting this context for switch hotbar methods Signed-off-by: Alex Andreev * Do not convert store methods to arrow functions Signed-off-by: Alex Andreev --- .../components/hotbar/hotbar-selector.tsx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/renderer/components/hotbar/hotbar-selector.tsx b/src/renderer/components/hotbar/hotbar-selector.tsx index 59e39605e2..d3d6b314e0 100644 --- a/src/renderer/components/hotbar/hotbar-selector.tsx +++ b/src/renderer/components/hotbar/hotbar-selector.tsx @@ -44,9 +44,14 @@ const NonInjectedHotbarSelector = observer(({ hotbar, hotbarStore, openCommandOv tooltipTimeout.current = setTimeout(() => setTooltipVisible(false), 1500); } - function onArrowClick(switchTo: () => void) { + function onPrevClick() { onTooltipShow(); - switchTo(); + hotbarStore.switchToPrevious(); + } + + function onNextClick() { + onTooltipShow(); + hotbarStore.switchToNext(); } function onMouseEvent(event: React.MouseEvent) { @@ -56,11 +61,7 @@ const NonInjectedHotbarSelector = observer(({ hotbar, hotbarStore, openCommandOv return (
- onArrowClick(hotbarStore.switchToPrevious)} - /> +
- onArrowClick(hotbarStore.switchToNext)} /> +
); });