Skip to content

Commit c937b91

Browse files
committed
Better handling of disabled buttons
1 parent c9883f5 commit c937b91

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

gui/src/components/commons/Tooltip.tsx

Lines changed: 11 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,11 @@ export function DrawerTooltip({
359363
}
360364
};
361365

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

0 commit comments

Comments
 (0)