Skip to content

Commit

Permalink
Fixed #2946 - Global Tooltip is not working with data-pr-classname
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed May 30, 2022
1 parent e712033 commit 91547ee
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions components/lib/tooltip/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { classNames, DomHandler, ObjectUtils, ZIndexUtils } from '../utils/Utils
export const Tooltip = React.memo(React.forwardRef((props, ref) => {
const [visibleState, setVisibleState] = React.useState(false);
const [positionState, setPositionState] = React.useState(props.position);
const [classNameState, setClassNameState] = React.useState('');
const elementRef = React.useRef(null);
const textRef = React.useRef(null);
const currentTargetRef = React.useRef(null);
Expand Down Expand Up @@ -147,9 +148,9 @@ export const Tooltip = React.memo(React.forwardRef((props, ref) => {
applyDelay('showDelay', () => {
setVisibleState(true);
setPositionState(getPosition(currentTargetRef.current));
setClassNameState(getTargetOption(currentTargetRef.current, 'classname'));
setTimeout(() => updateTooltipState(), 0);
sendCallback(props.onShow, { originalEvent: e, target: currentTargetRef.current });
DomHandler.addClass(currentTargetRef.current, getTargetOption(currentTargetRef.current, 'classname'));
});
};
}
Expand All @@ -159,8 +160,6 @@ export const Tooltip = React.memo(React.forwardRef((props, ref) => {
clearTimeouts();

if (visibleState) {
DomHandler.removeClass(currentTargetRef.current, getTargetOption(currentTargetRef.current, 'classname'));

const success = sendCallback(props.onBeforeHide, { originalEvent: e, target: currentTargetRef.current });
if (success) {
applyDelay('hideDelay', () => {
Expand All @@ -173,6 +172,7 @@ export const Tooltip = React.memo(React.forwardRef((props, ref) => {

setVisibleState(false);
setPositionState(props.position);
setClassNameState('');
currentTargetRef.current = null;
containerSize.current = null;
allowHide.current = true;
Expand Down Expand Up @@ -436,7 +436,7 @@ export const Tooltip = React.memo(React.forwardRef((props, ref) => {
const otherProps = ObjectUtils.findDiffKeys(props, Tooltip.defaultProps);
const tooltipClassName = classNames('p-tooltip p-component', {
[`p-tooltip-${positionState}`]: true
}, props.className);
}, props.className, classNameState);
const empty = isTargetContentEmpty(currentTargetRef.current);

return (
Expand Down

0 comments on commit 91547ee

Please sign in to comment.