@loomhq/lens 10.54.1 → 10.54.2

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.
@@ -71,22 +71,33 @@ const Tooltip = (_a) => {
71
71
  const [isOverTooltip, setIsOverTooltip] = useState(false);
72
72
  const [isOpen, setIsOpen] = useState(false);
73
73
  const focusRef = useRef();
74
+ const isTooltipDisabled = !content || isDisabled;
74
75
  // show the tooltip if a user has focused or hovered on it AND it is not disabled
75
76
  useEffect(() => {
76
- const isTooltipDisabled = !content || isDisabled;
77
+ const keepTooltipOpenOnHover = isOverTooltip && keepOpen;
77
78
  if (isTooltipDisabled) {
78
79
  return;
79
80
  }
80
- if (show || (isOverTooltip && keepOpen)) {
81
+ if (show || keepTooltipOpenOnHover) {
81
82
  setIsOpen(true);
82
83
  }
83
84
  // We have to watch this separately since hover and focus are managed separately. So, an element can be keyboard focused while another element is mouse hovered.
84
85
  if (!show) {
85
86
  setIsOpen(false);
86
87
  }
87
- }, [content, isDisabled, isOverTooltip, keepOpen, setIsOpen, show]);
88
+ }, [
89
+ content,
90
+ isDisabled,
91
+ isOverTooltip,
92
+ isTooltipDisabled,
93
+ keepOpen,
94
+ setIsOpen,
95
+ show,
96
+ ]);
88
97
  const handleFocus = () => {
89
- setIsOpen(true);
98
+ if (!isTooltipDisabled) {
99
+ setIsOpen(true);
100
+ }
90
101
  };
91
102
  const handleBlur = () => {
92
103
  setIsOpen(false);
@@ -115,7 +126,7 @@ const Tooltip = (_a) => {
115
126
  auto: true,
116
127
  });
117
128
  return (React.createElement(React.Fragment, null,
118
- React.createElement(TooltipChildren, Object.assign({}, triggerProps, hoverProps, { onFocus: handleFocus, onBlur: handleBlur, isInline: isInline, verticalAlign: verticalAlign, tabIndex: isDisabled ? -1 : tabIndex, ref: mergeRefs(triggerProps.ref, focusRef) }), children),
129
+ React.createElement(TooltipChildren, Object.assign({}, triggerProps, hoverProps, { onFocus: handleFocus, onBlur: handleBlur, isInline: isInline, verticalAlign: verticalAlign, tabIndex: isTooltipDisabled ? -1 : tabIndex, ref: mergeRefs(triggerProps.ref, focusRef) }), children),
119
130
  isOpen &&
120
131
  renderLayer(React.createElement("div", Object.assign({}, layerProps, { style: Object.assign(Object.assign({}, layerProps.style), { zIndex }) }),
121
132
  React.createElement(TooltipBox, Object.assign({ maxWidth: maxWidth, onMouseEnter: () => setIsOverTooltip(true), onMouseLeave: () => setIsOverTooltip(false) }, rest), content)))));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomhq/lens",
3
- "version": "10.54.1",
3
+ "version": "10.54.2",
4
4
  "scripts": {
5
5
  "dev": "next",
6
6
  "build:next": "next build",