@clayui/tooltip 3.79.0 → 3.80.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/TooltipProvider.js
CHANGED
|
@@ -156,7 +156,7 @@ var TooltipProvider = function TooltipProvider(_ref2) {
|
|
|
156
156
|
});
|
|
157
157
|
var onShow = (0, _react.useCallback)(function (event) {
|
|
158
158
|
if (isHovered.current || isFocused.current) {
|
|
159
|
-
var _props = getProps(event);
|
|
159
|
+
var _props = getProps(event, isHovered.current);
|
|
160
160
|
|
|
161
161
|
if (_props) {
|
|
162
162
|
var _ref3;
|
package/lib/useClosestTitle.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ declare type Props = {
|
|
|
9
9
|
tooltipRef: React.MutableRefObject<HTMLElement | null>;
|
|
10
10
|
};
|
|
11
11
|
export declare function useClosestTitle(props: Props): {
|
|
12
|
-
getProps: (event: React.MouseEvent<HTMLElement, MouseEvent
|
|
12
|
+
getProps: (event: React.MouseEvent<HTMLElement, MouseEvent>, hideBrowserTitle: boolean) => {
|
|
13
13
|
align: string | null;
|
|
14
14
|
delay: string | null;
|
|
15
15
|
floating: boolean;
|
package/lib/useClosestTitle.js
CHANGED
|
@@ -46,7 +46,6 @@ function useClosestTitle(props) {
|
|
|
46
46
|
var targetRef = (0, _react.useRef)(null);
|
|
47
47
|
var titleNodeRef = (0, _react.useRef)(null);
|
|
48
48
|
var saveTitle = (0, _react.useCallback)(function (element) {
|
|
49
|
-
titleNodeRef.current = element;
|
|
50
49
|
var title = element.getAttribute('title');
|
|
51
50
|
|
|
52
51
|
if (title) {
|
|
@@ -102,7 +101,7 @@ function useClosestTitle(props) {
|
|
|
102
101
|
targetRef.current = null;
|
|
103
102
|
}
|
|
104
103
|
}, []);
|
|
105
|
-
var getProps = (0, _react.useCallback)(function (event) {
|
|
104
|
+
var getProps = (0, _react.useCallback)(function (event, hideBrowserTitle) {
|
|
106
105
|
if (targetRef.current) {
|
|
107
106
|
props.onClick();
|
|
108
107
|
|
|
@@ -119,7 +118,12 @@ function useClosestTitle(props) {
|
|
|
119
118
|
targetRef.current = target;
|
|
120
119
|
target.addEventListener('click', onClick);
|
|
121
120
|
var title = node.getAttribute('title') || node.getAttribute('data-title') || '';
|
|
122
|
-
|
|
121
|
+
titleNodeRef.current = node;
|
|
122
|
+
|
|
123
|
+
if (hideBrowserTitle) {
|
|
124
|
+
saveTitle(node);
|
|
125
|
+
}
|
|
126
|
+
|
|
123
127
|
return {
|
|
124
128
|
align: node.getAttribute('data-tooltip-align'),
|
|
125
129
|
delay: node.getAttribute('data-tooltip-delay'),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clayui/tooltip",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.80.1",
|
|
4
4
|
"description": "ClayTooltip component",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"repository": "https://github.com/liferay/clay",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"react"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@clayui/shared": "^3.
|
|
29
|
+
"@clayui/shared": "^3.80.1",
|
|
30
30
|
"classnames": "^2.2.6",
|
|
31
31
|
"dom-align": "^1.12.2",
|
|
32
32
|
"warning": "^4.0.3"
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"browserslist": [
|
|
40
40
|
"extends browserslist-config-clay"
|
|
41
41
|
],
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "661fbbd771c0da17fb738536e11361416f631b2f"
|
|
43
43
|
}
|
package/src/TooltipProvider.tsx
CHANGED
|
@@ -159,7 +159,7 @@ const TooltipProvider = ({
|
|
|
159
159
|
const onShow = useCallback(
|
|
160
160
|
(event: React.MouseEvent<HTMLElement, MouseEvent>) => {
|
|
161
161
|
if (isHovered.current || isFocused.current) {
|
|
162
|
-
const props = getProps(event);
|
|
162
|
+
const props = getProps(event, isHovered.current);
|
|
163
163
|
|
|
164
164
|
if (props) {
|
|
165
165
|
dispatch({
|
package/src/useClosestTitle.ts
CHANGED
|
@@ -52,8 +52,6 @@ export function useClosestTitle(props: Props) {
|
|
|
52
52
|
const titleNodeRef = useRef<HTMLElement | null>(null);
|
|
53
53
|
|
|
54
54
|
const saveTitle = useCallback((element: HTMLElement) => {
|
|
55
|
-
titleNodeRef.current = element;
|
|
56
|
-
|
|
57
55
|
const title = element.getAttribute('title');
|
|
58
56
|
|
|
59
57
|
if (title) {
|
|
@@ -120,7 +118,10 @@ export function useClosestTitle(props: Props) {
|
|
|
120
118
|
}, []);
|
|
121
119
|
|
|
122
120
|
const getProps = useCallback(
|
|
123
|
-
(
|
|
121
|
+
(
|
|
122
|
+
event: React.MouseEvent<HTMLElement, MouseEvent>,
|
|
123
|
+
hideBrowserTitle: boolean
|
|
124
|
+
) => {
|
|
124
125
|
if (targetRef.current) {
|
|
125
126
|
props.onClick();
|
|
126
127
|
|
|
@@ -150,7 +151,11 @@ export function useClosestTitle(props: Props) {
|
|
|
150
151
|
node.getAttribute('data-title') ||
|
|
151
152
|
'';
|
|
152
153
|
|
|
153
|
-
|
|
154
|
+
titleNodeRef.current = node;
|
|
155
|
+
|
|
156
|
+
if (hideBrowserTitle) {
|
|
157
|
+
saveTitle(node);
|
|
158
|
+
}
|
|
154
159
|
|
|
155
160
|
return {
|
|
156
161
|
align: node.getAttribute('data-tooltip-align'),
|