@oliasoft-open-source/react-ui-library 4.15.1-beta-8 → 4.15.1-beta-10

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.
package/dist/index.js CHANGED
@@ -20886,6 +20886,7 @@ const Trigger = ({
20886
20886
  maxTooltipWidth,
20887
20887
  placeholder: placeholder3,
20888
20888
  right: right2,
20889
+ isMounted,
20889
20890
  testId
20890
20891
  }) => {
20891
20892
  var _a2;
@@ -20931,7 +20932,11 @@ const Trigger = ({
20931
20932
  onClick: (evt) => {
20932
20933
  onClickTrigger(evt);
20933
20934
  if (typeof setInputFocus === "function") {
20934
- setInputFocus();
20935
+ requestAnimationFrame(() => {
20936
+ if (isMounted == null ? void 0 : isMounted.current) {
20937
+ setInputFocus();
20938
+ }
20939
+ });
20935
20940
  }
20936
20941
  },
20937
20942
  onFocus,
@@ -21186,21 +21191,27 @@ const useCustomSelectLogic = ({
21186
21191
  firstSelectedOptionIndex,
21187
21192
  createAble,
21188
21193
  listRef,
21189
- autoLayerWidth
21194
+ autoLayerWidth,
21195
+ isMounted
21190
21196
  }) => {
21197
+ const safeDispatch = (action2) => {
21198
+ if (isMounted.current) {
21199
+ dispatch(action2);
21200
+ }
21201
+ };
21191
21202
  const closeLayer = () => {
21192
21203
  if (state.isLayerOpen) {
21193
- dispatch({ type: ActionTypes.CLOSE_LAYER });
21204
+ safeDispatch({ type: ActionTypes.CLOSE_LAYER });
21194
21205
  }
21195
21206
  setTriggerFocus();
21196
21207
  };
21197
- const openLayer = () => dispatch({ type: ActionTypes.OPEN_LAYER });
21208
+ const openLayer = () => safeDispatch({ type: ActionTypes.OPEN_LAYER });
21198
21209
  const isFirstRun = useRef(true);
21199
21210
  useEffect(() => {
21200
21211
  if (isFirstRun.current) {
21201
21212
  isFirstRun.current = false;
21202
21213
  } else {
21203
- dispatch({ type: ActionTypes.SET_VISIBLE_OPTIONS, options });
21214
+ safeDispatch({ type: ActionTypes.SET_VISIBLE_OPTIONS, options });
21204
21215
  }
21205
21216
  }, [options]);
21206
21217
  const onSelectOption = (evt, option2, close2) => {
@@ -21238,7 +21249,7 @@ const useCustomSelectLogic = ({
21238
21249
  }
21239
21250
  }
21240
21251
  }
21241
- dispatch({ type: ActionTypes.CLEAR_SEARCH, options });
21252
+ safeDispatch({ type: ActionTypes.CLEAR_SEARCH, options });
21242
21253
  setTriggerFocus();
21243
21254
  }
21244
21255
  };
@@ -21274,7 +21285,7 @@ const useCustomSelectLogic = ({
21274
21285
  closeLayer();
21275
21286
  return;
21276
21287
  }
21277
- dispatch({
21288
+ safeDispatch({
21278
21289
  type: ActionTypes.RESET_LAYER_FOCUS,
21279
21290
  options,
21280
21291
  firstSelectedOptionIndex
@@ -21287,7 +21298,7 @@ const useCustomSelectLogic = ({
21287
21298
  isFirstRender.current = false;
21288
21299
  } else {
21289
21300
  if (!state.isLayerOpen) {
21290
- dispatch({ type: ActionTypes.CLEAR_SEARCH, options });
21301
+ safeDispatch({ type: ActionTypes.CLEAR_SEARCH, options });
21291
21302
  }
21292
21303
  }
21293
21304
  }, [state.isLayerOpen]);
@@ -21303,7 +21314,7 @@ const useCustomSelectLogic = ({
21303
21314
  onChange(evt, newSelectedOptions);
21304
21315
  }
21305
21316
  };
21306
- const onChangeSearch = (value) => dispatch({
21317
+ const onChangeSearch = (value) => safeDispatch({
21307
21318
  type: ActionTypes.ON_CHANGE_SEARCH,
21308
21319
  options,
21309
21320
  value,
@@ -21311,7 +21322,7 @@ const useCustomSelectLogic = ({
21311
21322
  });
21312
21323
  const clickTrigger = () => {
21313
21324
  openLayer();
21314
- dispatch({ type: ActionTypes.BLUR_TRIGGER_INPUTS });
21325
+ safeDispatch({ type: ActionTypes.BLUR_TRIGGER_INPUTS });
21315
21326
  };
21316
21327
  const scrollToItem = (index2) => {
21317
21328
  if (listRef.current && Number.isInteger(index2)) {
@@ -21320,11 +21331,14 @@ const useCustomSelectLogic = ({
21320
21331
  };
21321
21332
  const focusNextLayerOption = (ICustomSelectDirection2) => {
21322
21333
  const next2 = nextLayerFocus(ICustomSelectDirection2, state.layerFocus);
21323
- dispatch({ type: ActionTypes.FOCUS_LAYER_OPTIONS, nextLayerFocus: next2 });
21334
+ safeDispatch({
21335
+ type: ActionTypes.FOCUS_LAYER_OPTIONS,
21336
+ nextLayerFocus: next2
21337
+ });
21324
21338
  scrollToItem(next2.current);
21325
21339
  };
21326
21340
  const focusTriggerInputs = (ICustomSelectDirection2) => {
21327
- dispatch({
21341
+ safeDispatch({
21328
21342
  type: ActionTypes.FOCUS_TRIGGER_INPUTS,
21329
21343
  ICustomSelectDirection: ICustomSelectDirection2,
21330
21344
  selectedOptions
@@ -21445,6 +21459,12 @@ const CustomSelect = (props) => {
21445
21459
  isLayerOpen: false
21446
21460
  })
21447
21461
  );
21462
+ const isMounted = useRef(true);
21463
+ useEffect(() => {
21464
+ return () => {
21465
+ isMounted.current = false;
21466
+ };
21467
+ }, []);
21448
21468
  const {
21449
21469
  getTriggerWidth,
21450
21470
  onKeyEvent,
@@ -21468,7 +21488,8 @@ const CustomSelect = (props) => {
21468
21488
  disabledContext,
21469
21489
  isFontLoaded,
21470
21490
  createAble,
21471
- listRef
21491
+ listRef,
21492
+ isMounted
21472
21493
  });
21473
21494
  return /* @__PURE__ */ jsx("div", { style: { width: getTriggerWidth() }, children: /* @__PURE__ */ jsxs(
21474
21495
  KeyboardEventHandler,
@@ -21504,7 +21525,8 @@ const CustomSelect = (props) => {
21504
21525
  maxTooltipWidth,
21505
21526
  placeholder: placeholder3,
21506
21527
  right: right2,
21507
- testId
21528
+ testId,
21529
+ isMounted
21508
21530
  }
21509
21531
  ),
21510
21532
  state.isLayerOpen && renderLayer(