diff --git a/api-generator/components/tooltip.js b/api-generator/components/tooltip.js
index 39292a1f7a..0e7734ae21 100644
--- a/api-generator/components/tooltip.js
+++ b/api-generator/components/tooltip.js
@@ -39,7 +39,7 @@ const TooltipProps = [
name: 'position',
type: 'string',
default: 'right',
- description: 'Position of the tooltip, valid values are right, left, top and bottom.'
+ description: 'Position of the tooltip, valid values are mouse, right, left, top and bottom.'
},
{
name: 'my',
diff --git a/components/doc/tooltip/index.js b/components/doc/tooltip/index.js
index cb840189a7..135e1f1ebc 100644
--- a/components/doc/tooltip/index.js
+++ b/components/doc/tooltip/index.js
@@ -36,18 +36,21 @@ export class TooltipDemo extends Component {
Positions
-
+
-
+
-
+
-
Focus and Blur
@@ -155,18 +158,21 @@ const TooltipDemo = () => {
Positions
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Focus and Blur
@@ -273,18 +279,21 @@ const TooltipDemo = () => {
Positions
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Focus and Blur
@@ -401,18 +410,21 @@ const TooltipDemo = () => {
Positions
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Focus and Blur
@@ -661,7 +673,7 @@ import { Tooltip } from 'primereact/tooltip';
position |
string |
right |
-
Position of the tooltip, valid values are right, left, top and bottom. |
+
Position of the tooltip, valid values are mouse, right, left, top and bottom. |
my |
diff --git a/components/lib/tooltip/Tooltip.js b/components/lib/tooltip/Tooltip.js
index 5b1da9bcfe..ba9859b9c9 100644
--- a/components/lib/tooltip/Tooltip.js
+++ b/components/lib/tooltip/Tooltip.js
@@ -128,7 +128,7 @@ export const Tooltip = React.memo(
elementRef.current.style.pointerEvents = 'none';
}
- if (isMouseTrack(currentTargetRef.current) && !containerSize.current) {
+ if ((isMouseTrack(currentTargetRef.current) || position == 'mouse') && !containerSize.current) {
containerSize.current = {
width: DomHandler.getOuterWidth(elementRef.current),
height: DomHandler.getOuterHeight(elementRef.current)
@@ -192,7 +192,7 @@ export const Tooltip = React.memo(
top = 0,
currentPosition = position || positionState;
- if (isMouseTrack(target) && coordinate) {
+ if ((isMouseTrack(target) || currentPosition == 'mouse') && coordinate) {
const _containerSize = {
width: DomHandler.getOuterWidth(elementRef.current),
height: DomHandler.getOuterHeight(elementRef.current)
@@ -209,6 +209,7 @@ export const Tooltip = React.memo(
top -= _containerSize.height / 2 - mouseTrackTop;
break;
case 'right':
+ case 'mouse':
left += mouseTrackLeft;
top -= _containerSize.height / 2 - mouseTrackTop;
break;
@@ -491,31 +492,31 @@ export const Tooltip = React.memo(
Tooltip.displayName = 'Tooltip';
Tooltip.defaultProps = {
__TYPE: 'Tooltip',
- id: null,
- target: null,
- content: null,
- disabled: false,
- className: null,
- style: null,
appendTo: null,
- position: 'right',
- my: null,
at: null,
- event: null,
- showEvent: 'mouseenter',
- hideEvent: 'mouseleave',
+ autoHide: true,
autoZIndex: true,
baseZIndex: 0,
+ className: null,
+ content: null,
+ disabled: false,
+ event: null,
+ hideDelay: 0,
+ hideEvent: 'mouseleave',
+ id: null,
mouseTrack: false,
- mouseTrackTop: 5,
mouseTrackLeft: 5,
- showDelay: 0,
- updateDelay: 0,
- hideDelay: 0,
- autoHide: true,
- showOnDisabled: false,
- onBeforeShow: null,
+ mouseTrackTop: 5,
+ my: null,
onBeforeHide: null,
+ onBeforeShow: null,
+ onHide: null,
onShow: null,
- onHide: null
+ position: 'right',
+ showDelay: 0,
+ showEvent: 'mouseenter',
+ showOnDisabled: false,
+ style: null,
+ target: null,
+ updateDelay: 0
};
diff --git a/components/lib/tooltip/tooltipoptions.d.ts b/components/lib/tooltip/tooltipoptions.d.ts
index 994f7bfc72..f3cefc800b 100644
--- a/components/lib/tooltip/tooltipoptions.d.ts
+++ b/components/lib/tooltip/tooltipoptions.d.ts
@@ -1,6 +1,6 @@
import * as React from 'react';
-type TooltipPositionType = 'top' | 'bottom' | 'left' | 'right';
+type TooltipPositionType = 'top' | 'bottom' | 'left' | 'right' | 'mouse';
type TooltipEventType = 'hover' | 'focus' | 'both';
@@ -12,26 +12,26 @@ interface TooltipEventParams {
}
export default interface TooltipOptions {
- className?: string;
- style?: React.CSSProperties;
appendTo?: TooltipAppendToType;
- position?: TooltipPositionType;
- my?: string;
at?: string;
- event?: TooltipEventType;
- showEvent?: string;
- hideEvent?: string;
+ autoHide?: boolean;
autoZIndex?: boolean;
baseZIndex?: number;
+ className?: string;
+ disabled?: boolean;
+ event?: TooltipEventType;
+ hideDelay?: number;
+ hideEvent?: string;
mouseTrack?: boolean;
- mouseTrackTop?: number;
mouseTrackLeft?: number;
+ mouseTrackTop?: number;
+ my?: string;
+ position?: TooltipPositionType;
showDelay?: number;
- updateDelay?: number;
- hideDelay?: number;
- autoHide?: boolean;
- disabled?: boolean;
+ showEvent?: string;
showOnDisabled?: boolean;
+ style?: React.CSSProperties;
+ updateDelay?: number;
onBeforeShow?(e: TooltipEventParams): void;
onBeforeHide?(e: TooltipEventParams): void;
onShow?(e: TooltipEventParams): void;
diff --git a/pages/tooltip/index.js b/pages/tooltip/index.js
index faa4fe6a52..a0d857c3cd 100644
--- a/pages/tooltip/index.js
+++ b/pages/tooltip/index.js
@@ -36,18 +36,21 @@ const TooltipDemo = () => {