1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix broken hotbar switcher (#5182)

* Getting this context for switch hotbar methods

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Do not convert store methods to arrow functions

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2022-04-06 14:28:07 +03:00 committed by GitHub
parent feb983c42c
commit 66330485b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,9 +44,14 @@ const NonInjectedHotbarSelector = observer(({ hotbar, hotbarStore, openCommandOv
tooltipTimeout.current = setTimeout(() => setTooltipVisible(false), 1500); tooltipTimeout.current = setTimeout(() => setTooltipVisible(false), 1500);
} }
function onArrowClick(switchTo: () => void) { function onPrevClick() {
onTooltipShow(); onTooltipShow();
switchTo(); hotbarStore.switchToPrevious();
}
function onNextClick() {
onTooltipShow();
hotbarStore.switchToNext();
} }
function onMouseEvent(event: React.MouseEvent) { function onMouseEvent(event: React.MouseEvent) {
@ -56,11 +61,7 @@ const NonInjectedHotbarSelector = observer(({ hotbar, hotbarStore, openCommandOv
return ( return (
<div className={styles.HotbarSelector}> <div className={styles.HotbarSelector}>
<Icon <Icon material="play_arrow" className={cssNames(styles.Icon, styles.previous)} onClick={onPrevClick}/>
material="play_arrow"
className={cssNames(styles.Icon, styles.previous)}
onClick={() => onArrowClick(hotbarStore.switchToPrevious)}
/>
<div className={styles.HotbarIndex}> <div className={styles.HotbarIndex}>
<Badge <Badge
id="hotbarIndex" id="hotbarIndex"
@ -79,7 +80,7 @@ const NonInjectedHotbarSelector = observer(({ hotbar, hotbarStore, openCommandOv
{hotbar.name} {hotbar.name}
</Tooltip> </Tooltip>
</div> </div>
<Icon material="play_arrow" className={styles.Icon} onClick={() => onArrowClick(hotbarStore.switchToNext)} /> <Icon material="play_arrow" className={styles.Icon} onClick={onNextClick} />
</div> </div>
); );
}); });