Skip to content

Commit 77cbccc

Browse files
committed
add suggested code improvements
1 parent bc26ab9 commit 77cbccc

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

src/components/ContextOverlay/ContextOverlay.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,22 @@ export const ContextOverlay = ({
6060
if (swapDelay.current) {
6161
clearTimeout(swapDelay.current);
6262
}
63+
64+
const replacePlaceholder = () => {
65+
eventMemory.current = ev.type as "mouseenter" | "focusin" | "click";
66+
setPlaceholder(false);
67+
};
68+
69+
if (waitForClick) {
70+
replacePlaceholder();
71+
return;
72+
}
73+
6374
swapDelay.current = setTimeout(
64-
() => {
65-
eventMemory.current = ev.type as "mouseenter" | "focusin" | "click";
66-
setPlaceholder(false);
67-
},
75+
replacePlaceholder,
6876
// we delay the swap for hover/focus to prevent unwanted effects
6977
// (e.g. event hickup after replacing elements when it is not really necessary)
70-
waitForClick ? 0 : swapDelayTime
78+
swapDelayTime
7179
);
7280
};
7381

0 commit comments

Comments
 (0)