Skip to content

Commit c32da0c

Browse files
committed
Refactor selection hint logic in toolbar component to improve user experience with active state handling
1 parent 270308c commit c32da0c

File tree

1 file changed

+6
-4
lines changed
  • packages/react-grab/src/components/toolbar

1 file changed

+6
-4
lines changed

packages/react-grab/src/components/toolbar/index.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,14 @@ export const Toolbar: Component<ToolbarProps> = (props) => {
167167
let clockFlashRef: HTMLSpanElement | undefined;
168168
const [selectionHintIndex, setSelectionHintIndex] = createSignal(0);
169169

170+
const hasLearnedSelectionHints = () => (props.clockFlashTrigger ?? 0) > 0;
171+
170172
createEffect(
171173
on(
172-
() => props.isActive,
173-
(isActive) => {
174+
() => [props.isActive, hasLearnedSelectionHints()] as const,
175+
([isActive, hasLearned]) => {
174176
setSelectionHintIndex(0);
175-
if (!isActive) return;
177+
if (!isActive || hasLearned) return;
176178
const intervalId = setInterval(() => {
177179
setSelectionHintIndex(
178180
(previous) => (previous + 1) % SELECTION_HINT_COUNT,
@@ -1761,7 +1763,7 @@ export const Toolbar: Component<ToolbarProps> = (props) => {
17611763
}
17621764
shakeTooltip={
17631765
<>
1764-
<Show when={props.isActive}>
1766+
<Show when={props.isActive && !hasLearnedSelectionHints()}>
17651767
<div
17661768
class={cn(
17671769
"absolute whitespace-nowrap flex items-center gap-1 px-1.5 py-0.5 rounded-[10px] text-[10px] text-black/60 pointer-events-none animate-tooltip-fade-in [animation-fill-mode:backwards] overflow-hidden [corner-shape:superellipse(1.25)]",

0 commit comments

Comments
 (0)