From 6d7cc7cfbfe584bd3bab97511853440f1504f73a Mon Sep 17 00:00:00 2001 From: ilan7empest Date: Tue, 17 Sep 2024 10:25:38 +0300 Subject: [PATCH] Create a new dist version 2.2.1 Collecting: - Fix [UI] UI crash when closing pop-up dialogs (#315) - Fix [Chips] Hidden chips block doesn't close (#316) - Tests [UI] Add Initial Workflow to Enable GitHub Actions for Forked Repositories (#319) --- commit_message | 8 +++---- dist/components/PopUpDialog/PopUpDialog.js | 28 ++++++++++++---------- dist/hooks/useChipCell.hook.js | 19 ++++++++------- package.json | 2 +- 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/commit_message b/commit_message index f383ad08..7a9160e7 100644 --- a/commit_message +++ b/commit_message @@ -1,8 +1,8 @@ -Create a new dist version 2.2.0 +Create a new dist version 2.2.1 Collecting: -- Fix [DRC] Apply ESLint & Prettier Formatting Adjustments (#312) -- Fix [Models endpoints monitoring, metrics] The 'Choose metrics' dropdown is closing unexpectedly (#311) -- Fix [Round Icon] Tooltip doesn't disappear (#313) +- Fix [UI] UI crash when closing pop-up dialogs (#315) +- Fix [Chips] Hidden chips block doesn't close (#316) +- Tests [UI] Add Initial Workflow to Enable GitHub Actions for Forked Repositories (#319) diff --git a/dist/components/PopUpDialog/PopUpDialog.js b/dist/components/PopUpDialog/PopUpDialog.js index 73784af0..642db72a 100644 --- a/dist/components/PopUpDialog/PopUpDialog.js +++ b/dist/components/PopUpDialog/PopUpDialog.js @@ -114,19 +114,21 @@ const PopUpDialog = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => { calculateCustomPopUpPosition(); }, [calculateCustomPopUpPosition]); (0, _react.useEffect)(() => { - const throttledCalculatedCustomPopUpPosition = (0, _lodash.throttle)(calculateCustomPopUpPosition, 100, { - trailing: true, - leading: true - }); - const popupObserver = new ResizeObserver(throttledCalculatedCustomPopUpPosition); - const popupElement = ref.current; - popupObserver.observe(popupElement); - window.addEventListener('resize', throttledCalculatedCustomPopUpPosition); - return () => { - popupObserver.unobserve(popupElement); - window.removeEventListener('resize', throttledCalculatedCustomPopUpPosition); - }; - }, [calculateCustomPopUpPosition, ref]); + if (showPopUp) { + const throttledCalculatedCustomPopUpPosition = (0, _lodash.throttle)(calculateCustomPopUpPosition, 100, { + trailing: true, + leading: true + }); + const popupObserver = new ResizeObserver(throttledCalculatedCustomPopUpPosition); + const popupElement = ref.current; + popupObserver.observe(popupElement); + window.addEventListener('resize', throttledCalculatedCustomPopUpPosition); + return () => { + popupObserver.unobserve(popupElement); + window.removeEventListener('resize', throttledCalculatedCustomPopUpPosition); + }; + } + }, [calculateCustomPopUpPosition, ref, showPopUp]); return showPopUp ? /*#__PURE__*/(0, _reactDom.createPortal)( /*#__PURE__*/(0, _jsxRuntime.jsx)("div", { ref: ref, className: popUpClassNames, diff --git a/dist/hooks/useChipCell.hook.js b/dist/hooks/useChipCell.hook.js index 41df0a43..69c03a0d 100644 --- a/dist/hooks/useChipCell.hook.js +++ b/dist/hooks/useChipCell.hook.js @@ -39,21 +39,22 @@ const useChipCell = (isEditMode, visibleChipsMaxLength) => { const hiddenChipsCounterRef = (0, _react.useRef)(); const hiddenChipsPopUpRef = (0, _react.useRef)(); const handleShowElements = (0, _react.useCallback)(event => { + var _hiddenChipsCounterRe2; if (!isEditMode || isEditMode && visibleChipsMaxLength) { var _hiddenChipsCounterRe; - if (!((_hiddenChipsCounterRe = hiddenChipsCounterRef.current) !== null && _hiddenChipsCounterRe !== void 0 && _hiddenChipsCounterRe.contains(event.target))) { - setShowHiddenChips(false); - } else { + if ((_hiddenChipsCounterRe = hiddenChipsCounterRef.current) !== null && _hiddenChipsCounterRe !== void 0 && _hiddenChipsCounterRe.contains(event.target) && !showHiddenChips) { setShowHiddenChips(true); + } else { + setShowHiddenChips(false); } } - event && event.stopPropagation(); - }, [isEditMode, visibleChipsMaxLength]); + event && ((_hiddenChipsCounterRe2 = hiddenChipsCounterRef.current) === null || _hiddenChipsCounterRe2 === void 0 ? void 0 : _hiddenChipsCounterRe2.contains(event.target)) && event.stopPropagation(); + }, [isEditMode, showHiddenChips, visibleChipsMaxLength]); (0, _react.useEffect)(() => { if (showHiddenChips) { - window.addEventListener('click', handleShowElements); - return () => window.removeEventListener('click', handleShowElements); + window.addEventListener('click', handleShowElements, true); } + return () => window.removeEventListener('click', handleShowElements, true); }, [showHiddenChips, handleShowElements]); const handleScroll = (0, _react.useCallback)(event => { if (event.target.parentElement !== (hiddenChipsPopUpRef === null || hiddenChipsPopUpRef === void 0 ? void 0 : hiddenChipsPopUpRef.current)) { @@ -68,10 +69,10 @@ const useChipCell = (isEditMode, visibleChipsMaxLength) => { }, [handleScroll, showHiddenChips]); const resizeChipCell = (0, _react.useCallback)(() => { if (hiddenChipsPopUpRef !== null && hiddenChipsPopUpRef !== void 0 && hiddenChipsPopUpRef.current) { - var _hiddenChipsCounterRe2; + var _hiddenChipsCounterRe3; const scrollableParent = (0, _getFirstScrollableParent.getFirstScrollableParent)(hiddenChipsCounterRef.current.offsetParent); const scrollableParentRect = scrollableParent.getBoundingClientRect(); - const hiddenChipsCounterRect = (_hiddenChipsCounterRe2 = hiddenChipsCounterRef.current) === null || _hiddenChipsCounterRe2 === void 0 ? void 0 : _hiddenChipsCounterRe2.getBoundingClientRect(); + const hiddenChipsCounterRect = (_hiddenChipsCounterRe3 = hiddenChipsCounterRef.current) === null || _hiddenChipsCounterRe3 === void 0 ? void 0 : _hiddenChipsCounterRe3.getBoundingClientRect(); // Check if the hiddenChipsCounterRect is outside the boundaries of the scrollableParentRect or the window if (hiddenChipsCounterRect.left < scrollableParentRect.left || hiddenChipsCounterRect.top < scrollableParentRect.top || hiddenChipsCounterRect.right > scrollableParentRect.right || hiddenChipsCounterRect.bottom > scrollableParentRect.bottom || hiddenChipsCounterRect.right > window.innerWidth || hiddenChipsCounterRect.bottom > window.innerHeight) { diff --git a/package.json b/package.json index 39429e08..7b9eb04a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "iguazio.dashboard-react-controls", - "version": "2.2.0", + "version": "2.2.1", "description": "Collection of resources (such as CSS styles, fonts and images) and ReactJS 17.x components to share among different Iguazio React repos.", "main": "dist/index.js", "module": "dist/index.js",