@jetbrains/ring-ui 6.0.66 → 6.0.67
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.
|
@@ -56,6 +56,7 @@ export default class Tooltip extends Component<TooltipProps> {
|
|
|
56
56
|
showPopup: () => void;
|
|
57
57
|
hidePopup: () => void;
|
|
58
58
|
addListeners(): void;
|
|
59
|
+
hideIfMovedOutsidePopup: (ev: React.SyntheticEvent<HTMLElement>) => void;
|
|
59
60
|
popup?: Popup | null;
|
|
60
61
|
popupRef: (el: Popup | null) => void;
|
|
61
62
|
onNestedTooltipShow: () => void;
|
|
@@ -106,6 +106,13 @@ export default class Tooltip extends Component {
|
|
|
106
106
|
}
|
|
107
107
|
this.listeners.add(document, 'scroll', () => scheduleScroll(this.hidePopup), { passive: true });
|
|
108
108
|
}
|
|
109
|
+
hideIfMovedOutsidePopup = (ev) => {
|
|
110
|
+
if (!('relatedTarget' in ev) ||
|
|
111
|
+
this.popup?.container?.contains(ev.relatedTarget)) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
this.hidePopup();
|
|
115
|
+
};
|
|
109
116
|
popup;
|
|
110
117
|
popupRef = (el) => {
|
|
111
118
|
this.popup = el;
|
|
@@ -125,7 +132,7 @@ export default class Tooltip extends Component {
|
|
|
125
132
|
return (<TooltipContext.Provider value={{ onNestedTooltipShow, onNestedTooltipHide }}>
|
|
126
133
|
<span {...ariaProps} {...restProps} ref={this.containerRef} data-test={dataTests('ring-tooltip', dataTest)} data-test-title={typeof title === 'string' ? title : undefined}>
|
|
127
134
|
{children}
|
|
128
|
-
<Popup trapFocus={false} hidden={!this.state.showPopup || this.state.showNestedPopup} onCloseAttempt={this.hidePopup} maxHeight={400} className={classNames(styles.tooltip, { [styles.long]: long })} attached={false} onMouseOut={this.
|
|
135
|
+
<Popup trapFocus={false} 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 ref={this.popupRef} {...popupProps}>{title}</Popup>
|
|
129
136
|
</span>
|
|
130
137
|
</TooltipContext.Provider>);
|
|
131
138
|
}
|