@ultraviolet/ui 1.21.0 → 1.21.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.
|
@@ -70,12 +70,12 @@ const FwdMenu = /*#__PURE__*/forwardRef((_ref7, ref) => {
|
|
|
70
70
|
|
|
71
71
|
// Focus the first item when the menu is opened
|
|
72
72
|
if (!isVisible) {
|
|
73
|
-
|
|
73
|
+
setTimeout(() => {
|
|
74
74
|
// We have to wait for the popup to be inserted in the DOM
|
|
75
75
|
if (popupRef.current?.firstChild?.firstChild instanceof HTMLElement) {
|
|
76
76
|
popupRef.current.firstChild.firstChild.focus();
|
|
77
77
|
}
|
|
78
|
-
});
|
|
78
|
+
}, 1);
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
81
|
const onClose = () => {
|
|
@@ -267,7 +267,7 @@ const Popup = /*#__PURE__*/forwardRef((_ref13, ref) => {
|
|
|
267
267
|
const handleClickOutside = event => {
|
|
268
268
|
const tooltipCurrent = innerTooltipRef.current;
|
|
269
269
|
const childrenCurrent = childrenRef.current;
|
|
270
|
-
if (tooltipCurrent && hideOnClickOutside) {
|
|
270
|
+
if (tooltipCurrent && hideOnClickOutside && !event.defaultPrevented) {
|
|
271
271
|
if (event.target && event.target !== tooltipCurrent && event.target !== childrenCurrent && !childrenCurrent?.contains(event.target) && !tooltipCurrent.contains(event.target)) {
|
|
272
272
|
event.preventDefault();
|
|
273
273
|
event.stopPropagation();
|
|
@@ -277,11 +277,11 @@ const Popup = /*#__PURE__*/forwardRef((_ref13, ref) => {
|
|
|
277
277
|
};
|
|
278
278
|
if (visibleInDom) {
|
|
279
279
|
document.body.addEventListener('keyup', handleEscPress);
|
|
280
|
-
document.body.addEventListener('
|
|
280
|
+
document.body.addEventListener('click', handleClickOutside);
|
|
281
281
|
}
|
|
282
282
|
return () => {
|
|
283
283
|
document.body.removeEventListener('keyup', handleEscPress);
|
|
284
|
-
document.body.removeEventListener('
|
|
284
|
+
document.body.removeEventListener('click', handleClickOutside);
|
|
285
285
|
};
|
|
286
286
|
}, [hideTooltip, visibleInDom, innerTooltipRef, childrenRef, hideOnClickOutside]);
|
|
287
287
|
|
|
@@ -322,6 +322,13 @@ const Popup = /*#__PURE__*/forwardRef((_ref13, ref) => {
|
|
|
322
322
|
children: children
|
|
323
323
|
});
|
|
324
324
|
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* This event handle allow us to not bubble the event to document.body like this react-select works fine
|
|
328
|
+
*/
|
|
329
|
+
const stopClickPropagation = event => {
|
|
330
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
331
|
+
};
|
|
325
332
|
return jsxs(Fragment, {
|
|
326
333
|
children: [renderChildren(), visibleInDom ? /*#__PURE__*/createPortal(jsx(StyledTooltip, {
|
|
327
334
|
ref: innerTooltipRef,
|
|
@@ -333,6 +340,7 @@ const Popup = /*#__PURE__*/forwardRef((_ref13, ref) => {
|
|
|
333
340
|
reverseAnimation: reverseAnimation,
|
|
334
341
|
"data-testid": dataTestId,
|
|
335
342
|
"data-has-arrow": hasArrow,
|
|
343
|
+
onClick: stopClickPropagation,
|
|
336
344
|
children: text
|
|
337
345
|
}), document.body) : null]
|
|
338
346
|
});
|