fix(style): esc hint flickering
This commit is contained in:
@@ -46,14 +46,26 @@ export function useEscHint(options?: {
|
|||||||
const { styles } = useStyles();
|
const { styles } = useStyles();
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const timeoutRef = useRef<any>(null);
|
const timeoutRef = useRef<any>(null);
|
||||||
|
const isHintActiveRef = useRef(false);
|
||||||
|
|
||||||
const showHintThrottled = useMemo(
|
const showHintThrottled = useMemo(
|
||||||
() =>
|
() =>
|
||||||
throttle(
|
throttle(
|
||||||
() => {
|
() => {
|
||||||
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
if (isHintActiveRef.current) return;
|
||||||
|
|
||||||
|
isHintActiveRef.current = true;
|
||||||
|
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
timeoutRef.current = setTimeout(() => setVisible(false), 2000);
|
|
||||||
|
if (timeoutRef.current) {
|
||||||
|
clearTimeout(timeoutRef.current);
|
||||||
|
}
|
||||||
|
|
||||||
|
timeoutRef.current = setTimeout(() => {
|
||||||
|
setVisible(false);
|
||||||
|
isHintActiveRef.current = false;
|
||||||
|
}, 2000);
|
||||||
},
|
},
|
||||||
throttleDelay,
|
throttleDelay,
|
||||||
{
|
{
|
||||||
@@ -67,6 +79,7 @@ export function useEscHint(options?: {
|
|||||||
useHotkeys(
|
useHotkeys(
|
||||||
HotKeys.ESC,
|
HotKeys.ESC,
|
||||||
() => {
|
() => {
|
||||||
|
if (!enabled) return;
|
||||||
showHintThrottled();
|
showHintThrottled();
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user