Skip to content

Commit 4f1fd82

Browse files
authored
Tooltip: Better handling of disabled buttons (#1665)
2 parents 2d1f32b + f6ccb59 commit 4f1fd82

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

gui/src/components/commons/Tooltip.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,13 @@ export function DrawerTooltip({
344344
elem.classList.add(classNames('animate-pulse'));
345345
elem.classList.add(classNames('scale-[110%]'));
346346
elem.classList.add(classNames('duration-500'));
347-
touchTimeout.current = setTimeout(() => {
347+
if (elem.hasAttribute('disabled')) {
348348
open();
349-
}, TOOLTIP_DELAY) as unknown as number;
349+
} else {
350+
touchTimeout.current = setTimeout(() => {
351+
open();
352+
}, TOOLTIP_DELAY) as unknown as number;
353+
}
350354
}
351355
};
352356

@@ -359,7 +363,14 @@ export function DrawerTooltip({
359363
}
360364
};
361365

362-
const touchEnd = () => {
366+
const touchEnd = (e: MouseEvent | TouchEvent) => {
367+
if (
368+
e.currentTarget instanceof HTMLButtonElement &&
369+
e.currentTarget.hasAttribute('disabled')
370+
) {
371+
e.preventDefault();
372+
return;
373+
}
363374
if (Date.now() - touchTimestamp.current < TOOLTIP_DELAY) {
364375
clearTimeout(touchTimeout.current);
365376
close();

0 commit comments

Comments
 (0)