iguazio.dashboard-react-controls 2.2.0 → 2.2.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.
@@ -114,19 +114,21 @@ const PopUpDialog = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
114
114
  calculateCustomPopUpPosition();
115
115
  }, [calculateCustomPopUpPosition]);
116
116
  (0, _react.useEffect)(() => {
117
- const throttledCalculatedCustomPopUpPosition = (0, _lodash.throttle)(calculateCustomPopUpPosition, 100, {
118
- trailing: true,
119
- leading: true
120
- });
121
- const popupObserver = new ResizeObserver(throttledCalculatedCustomPopUpPosition);
122
- const popupElement = ref.current;
123
- popupObserver.observe(popupElement);
124
- window.addEventListener('resize', throttledCalculatedCustomPopUpPosition);
125
- return () => {
126
- popupObserver.unobserve(popupElement);
127
- window.removeEventListener('resize', throttledCalculatedCustomPopUpPosition);
128
- };
129
- }, [calculateCustomPopUpPosition, ref]);
117
+ if (showPopUp) {
118
+ const throttledCalculatedCustomPopUpPosition = (0, _lodash.throttle)(calculateCustomPopUpPosition, 100, {
119
+ trailing: true,
120
+ leading: true
121
+ });
122
+ const popupObserver = new ResizeObserver(throttledCalculatedCustomPopUpPosition);
123
+ const popupElement = ref.current;
124
+ popupObserver.observe(popupElement);
125
+ window.addEventListener('resize', throttledCalculatedCustomPopUpPosition);
126
+ return () => {
127
+ popupObserver.unobserve(popupElement);
128
+ window.removeEventListener('resize', throttledCalculatedCustomPopUpPosition);
129
+ };
130
+ }
131
+ }, [calculateCustomPopUpPosition, ref, showPopUp]);
130
132
  return showPopUp ? /*#__PURE__*/(0, _reactDom.createPortal)( /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
131
133
  ref: ref,
132
134
  className: popUpClassNames,
@@ -39,21 +39,22 @@ const useChipCell = (isEditMode, visibleChipsMaxLength) => {
39
39
  const hiddenChipsCounterRef = (0, _react.useRef)();
40
40
  const hiddenChipsPopUpRef = (0, _react.useRef)();
41
41
  const handleShowElements = (0, _react.useCallback)(event => {
42
+ var _hiddenChipsCounterRe2;
42
43
  if (!isEditMode || isEditMode && visibleChipsMaxLength) {
43
44
  var _hiddenChipsCounterRe;
44
- if (!((_hiddenChipsCounterRe = hiddenChipsCounterRef.current) !== null && _hiddenChipsCounterRe !== void 0 && _hiddenChipsCounterRe.contains(event.target))) {
45
- setShowHiddenChips(false);
46
- } else {
45
+ if ((_hiddenChipsCounterRe = hiddenChipsCounterRef.current) !== null && _hiddenChipsCounterRe !== void 0 && _hiddenChipsCounterRe.contains(event.target) && !showHiddenChips) {
47
46
  setShowHiddenChips(true);
47
+ } else {
48
+ setShowHiddenChips(false);
48
49
  }
49
50
  }
50
- event && event.stopPropagation();
51
- }, [isEditMode, visibleChipsMaxLength]);
51
+ event && ((_hiddenChipsCounterRe2 = hiddenChipsCounterRef.current) === null || _hiddenChipsCounterRe2 === void 0 ? void 0 : _hiddenChipsCounterRe2.contains(event.target)) && event.stopPropagation();
52
+ }, [isEditMode, showHiddenChips, visibleChipsMaxLength]);
52
53
  (0, _react.useEffect)(() => {
53
54
  if (showHiddenChips) {
54
- window.addEventListener('click', handleShowElements);
55
- return () => window.removeEventListener('click', handleShowElements);
55
+ window.addEventListener('click', handleShowElements, true);
56
56
  }
57
+ return () => window.removeEventListener('click', handleShowElements, true);
57
58
  }, [showHiddenChips, handleShowElements]);
58
59
  const handleScroll = (0, _react.useCallback)(event => {
59
60
  if (event.target.parentElement !== (hiddenChipsPopUpRef === null || hiddenChipsPopUpRef === void 0 ? void 0 : hiddenChipsPopUpRef.current)) {
@@ -68,10 +69,10 @@ const useChipCell = (isEditMode, visibleChipsMaxLength) => {
68
69
  }, [handleScroll, showHiddenChips]);
69
70
  const resizeChipCell = (0, _react.useCallback)(() => {
70
71
  if (hiddenChipsPopUpRef !== null && hiddenChipsPopUpRef !== void 0 && hiddenChipsPopUpRef.current) {
71
- var _hiddenChipsCounterRe2;
72
+ var _hiddenChipsCounterRe3;
72
73
  const scrollableParent = (0, _getFirstScrollableParent.getFirstScrollableParent)(hiddenChipsCounterRef.current.offsetParent);
73
74
  const scrollableParentRect = scrollableParent.getBoundingClientRect();
74
- const hiddenChipsCounterRect = (_hiddenChipsCounterRe2 = hiddenChipsCounterRef.current) === null || _hiddenChipsCounterRe2 === void 0 ? void 0 : _hiddenChipsCounterRe2.getBoundingClientRect();
75
+ const hiddenChipsCounterRect = (_hiddenChipsCounterRe3 = hiddenChipsCounterRef.current) === null || _hiddenChipsCounterRe3 === void 0 ? void 0 : _hiddenChipsCounterRe3.getBoundingClientRect();
75
76
 
76
77
  // Check if the hiddenChipsCounterRect is outside the boundaries of the scrollableParentRect or the window
77
78
  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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iguazio.dashboard-react-controls",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "Collection of resources (such as CSS styles, fonts and images) and ReactJS 17.x components to share among different Iguazio React repos.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",