@jetbrains/ring-ui 7.0.18 → 7.0.19
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.
|
@@ -50,6 +50,7 @@ export default class Tooltip extends Component<TooltipProps> {
|
|
|
50
50
|
showPopup: () => void;
|
|
51
51
|
hidePopup: () => void;
|
|
52
52
|
addListeners(): void;
|
|
53
|
+
hideIfMovedOutsidePopup: (ev: React.SyntheticEvent<HTMLElement>) => void;
|
|
53
54
|
popup?: Popup | null;
|
|
54
55
|
popupRef: (el: Popup | null) => void;
|
|
55
56
|
onNestedTooltipShow: () => void;
|
|
@@ -99,6 +99,12 @@ export default class Tooltip extends Component {
|
|
|
99
99
|
}
|
|
100
100
|
this.listeners.add(document, 'scroll', () => scheduleScroll(this.hidePopup), { passive: true });
|
|
101
101
|
}
|
|
102
|
+
hideIfMovedOutsidePopup = (ev) => {
|
|
103
|
+
if (!('relatedTarget' in ev) || this.popup?.container?.contains(ev.relatedTarget)) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
this.hidePopup();
|
|
107
|
+
};
|
|
102
108
|
popup;
|
|
103
109
|
popupRef = (el) => {
|
|
104
110
|
this.popup = el;
|
|
@@ -113,6 +119,6 @@ export default class Tooltip extends Component {
|
|
|
113
119
|
const { children, 'data-test': dataTest, title, delay, theme, selfOverflowOnly, popupProps, long, ...restProps } = this.props;
|
|
114
120
|
const ariaProps = typeof title === 'string' && !!title ? { 'aria-label': title, role: 'tooltip' } : {};
|
|
115
121
|
const { onNestedTooltipShow, onNestedTooltipHide } = this;
|
|
116
|
-
return (_jsx(TooltipContext.Provider, { value: { onNestedTooltipShow, onNestedTooltipHide }, children: _jsxs("span", { ...ariaProps, ...restProps, ref: this.containerRef, "data-test": dataTests('ring-tooltip', dataTest), "data-test-title": typeof title === 'string' ? title : undefined, children: [children, _jsx(ThemeProvider, { theme: theme, passToPopups: true, WrapperComponent: props => _jsx("span", { ...props }), children: _jsx(Popup, { trapFocus: false, anchorElement: this.containerNode, hidden: !this.state.showPopup || this.state.showNestedPopup, onCloseAttempt: this.hidePopup, maxHeight: 400, className: classNames(styles.tooltip, { [styles.long]: long }), attached: false, onMouseOut: this.
|
|
122
|
+
return (_jsx(TooltipContext.Provider, { value: { onNestedTooltipShow, onNestedTooltipHide }, children: _jsxs("span", { ...ariaProps, ...restProps, ref: this.containerRef, "data-test": dataTests('ring-tooltip', dataTest), "data-test-title": typeof title === 'string' ? title : undefined, children: [children, _jsx(ThemeProvider, { theme: theme, passToPopups: true, WrapperComponent: props => _jsx("span", { ...props }), children: _jsx(Popup, { trapFocus: false, anchorElement: this.containerNode, hidden: !this.state.showPopup || this.state.showNestedPopup, onCloseAttempt: this.hidePopup, maxHeight: 400, className: classNames(styles.tooltip, { [styles.long]: long }), attached: false, onMouseOut: this.hideIfMovedOutsidePopup, top: 4, dontCloseOnAnchorClick: true, ref: this.popupRef, ...popupProps, children: title }) })] }) }));
|
|
117
123
|
}
|
|
118
124
|
}
|