Skip to content

Commit 0675b6c

Browse files
committed
refactor: fix tooltip focus management
1 parent c9bd155 commit 0675b6c

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

apps/showcase/demo/styled/tooltip/with-togglebutton-demo.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const content = [
2727
];
2828

2929
export default function WithToggleButtonDemo() {
30+
return null;
3031
return (
3132
<div className="flex items-center justify-center">
3233
<Tooltip.Manager>

packages/@primereact/headless/src/tooltip/useTooltip.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,20 @@ export const useTooltip = withHeadless({
225225
return;
226226
}
227227

228+
if (!anchorRef.current?.matches(':focus-visible')) {
229+
return;
230+
}
231+
228232
openTooltip(0, 'focus');
229233
};
230234

231235
handlersRef.current.onBlur = () => {
232236
suppressFocusRef.current = false;
237+
238+
if (!document.hasFocus()) {
239+
return;
240+
}
241+
233242
closeTooltip(0, 'focus');
234243
};
235244

0 commit comments

Comments
 (0)