Skip to content

Commit

Permalink
fix: primefaces#6680, Tooltip: Escape key not dismissing tooltip (WCA…
Browse files Browse the repository at this point in the history
…G 2.1 1.4.13)
  • Loading branch information
ANTONA09 committed May 27, 2024
1 parent 38faf1e commit 7e5694f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions components/lib/hooks/useGlobalOnEscapeKey.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { DomHandler } from '../utils/Utils';
* Priorities of different components (bigger number handled first)
*/
export const ESC_KEY_HANDLING_PRIORITIES = {
TOOLTIP: 10,
SIDEBAR: 100,
SLIDE_MENU: 200,
DIALOG: 300,
Expand Down
9 changes: 8 additions & 1 deletion components/lib/tooltip/Tooltip.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import PrimeReact, { PrimeReactContext } from '../api/Api';
import { useHandleStyle } from '../componentbase/ComponentBase';
import { useMergeProps, useMountEffect, useOverlayScrollListener, useResizeListener, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
import { useMergeProps, useMountEffect, useOverlayScrollListener, useResizeListener, useUnmountEffect, useUpdateEffect, useGlobalOnEscapeKey, ESC_KEY_HANDLING_PRIORITIES } from '../hooks/Hooks';
import { Portal } from '../portal/Portal';
import { DomHandler, ObjectUtils, ZIndexUtils, classNames } from '../utils/Utils';
import { TooltipBase } from './TooltipBase';
Expand Down Expand Up @@ -32,6 +32,13 @@ export const Tooltip = React.memo(
const { ptm, cx, sx, isUnstyled } = TooltipBase.setMetaData(metaData);

useHandleStyle(TooltipBase.css.styles, isUnstyled, { name: 'tooltip' });
useGlobalOnEscapeKey({
callback: () => {
hide();
},
when: props.closeOnEscape,
priority: [ESC_KEY_HANDLING_PRIORITIES.TOOLTIP, 0]
});
const elementRef = React.useRef(null);
const textRef = React.useRef(null);
const currentTargetRef = React.useRef(null);
Expand Down

0 comments on commit 7e5694f

Please sign in to comment.