fis-component 0.0.93 → 0.0.95

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/esm/index.js CHANGED
@@ -73673,8 +73673,9 @@ const FISSelect = forwardRef(({ className, style, size = "md", options, value, d
73673
73673
  }
73674
73674
  }, [multi, value, multiDisplayText, selectedItems, displayValue]);
73675
73675
  const handleToggle = useCallback(() => {
73676
- if (!disabled)
73676
+ if (!disabled) {
73677
73677
  setIsOpen((prev) => !prev);
73678
+ }
73678
73679
  }, [disabled]);
73679
73680
  const handleOptionRemove = useCallback((option) => {
73680
73681
  if (multi && Array.isArray(value)) {
@@ -73683,48 +73684,32 @@ const FISSelect = forwardRef(({ className, style, size = "md", options, value, d
73683
73684
  }
73684
73685
  }, [multi, onChange, value]);
73685
73686
  const handleMenuChange = useCallback((values) => {
73686
- console.log("Starting selection, blocking onBlur"); // Debug log
73687
- isSelectingRef.current = true;
73688
73687
  if (multi) {
73689
73688
  onChange(values);
73690
- isSelectingRef.current = false;
73691
73689
  }
73692
73690
  else {
73693
73691
  if (values.length > 0) {
73694
73692
  onChange(values[0]);
73695
73693
  setIsOpen(false);
73696
- // Reset selecting flag after a longer delay to ensure validation completes
73697
- setTimeout(() => {
73698
- console.log("Selection complete, allowing onBlur"); // Debug log
73699
- isSelectingRef.current = false;
73700
- }, 100);
73701
73694
  }
73702
73695
  }
73703
73696
  }, [multi, onChange]);
73704
73697
  const handleMenuClick = useCallback(() => {
73705
73698
  if (!multi) {
73706
- console.log("Menu click, setting isSelecting to true"); // Debug log
73707
- isSelectingRef.current = true;
73708
73699
  setIsOpen(false);
73709
- setTimeout(() => {
73710
- console.log("Menu click complete, allowing onBlur"); // Debug log
73711
- isSelectingRef.current = false;
73712
- }, 100);
73713
73700
  }
73714
73701
  }, [multi]);
73715
73702
  // Handle onBlur to prevent validation flash during selection
73716
73703
  const handleBlur = useCallback((event) => {
73717
- // Don't trigger onBlur validation if user is currently selecting an option
73718
- if (isSelectingRef.current) {
73719
- console.log("Blocking onBlur during selection"); // Debug log
73704
+ // Block onBlur if dropdown is open OR we're in the middle of selection
73705
+ if (isOpen || isSelectingRef.current) {
73720
73706
  return;
73721
73707
  }
73722
- console.log("Allowing onBlur to proceed"); // Debug log
73723
73708
  // Call original onBlur if provided
73724
73709
  if (restProps.onBlur) {
73725
73710
  restProps.onBlur(event);
73726
73711
  }
73727
- }, [restProps]);
73712
+ }, [isOpen, restProps]);
73728
73713
  const menuProps = useMemo$1(() => ({
73729
73714
  groups: options,
73730
73715
  placeholder: placeholderSearch,
@@ -73773,6 +73758,17 @@ const FISSelect = forwardRef(({ className, style, size = "md", options, value, d
73773
73758
  document.addEventListener("mousedown", handleClickOutside);
73774
73759
  return () => document.removeEventListener("mousedown", handleClickOutside);
73775
73760
  }, [isOpen, referenceElement, popperElement]);
73761
+ // Add delay after dropdown closes to ensure validation processes
73762
+ useEffect(() => {
73763
+ if (!isOpen && !multi) {
73764
+ // When dropdown closes, give time for value to be processed before allowing onBlur
73765
+ isSelectingRef.current = true;
73766
+ const timer = setTimeout(() => {
73767
+ isSelectingRef.current = false;
73768
+ }, 200);
73769
+ return () => clearTimeout(timer);
73770
+ }
73771
+ }, [isOpen, multi]);
73776
73772
  return (jsxs(DivWrapperSC$1, { className: className, style: style, children: [(textLabel || iconLabel) && (jsx(FISInputLabel, { textLabel: textLabel, required: required, iconLabel: iconLabel, onClickIconLabel: onClickIconLabel })), jsx(DivInputWrapperSC, { ref: setReferenceElement, onClick: handleToggle, "$hasValue": !!value, children: jsx(FISSelectItem, { ...restProps, onBlur: handleBlur, ref: ref, size: size, placeholder: placeholder, iconSuffix: isOpen ? jsx(ArrowUpIcon, {}) : jsx(ArrowDownIcon, {}), value: computedDisplayValue, disabled: disabled, activeDropdown: isOpen, negative: negative }) }), message && (jsx(SpanHintSC$3, { className: classNames({ disabled, negative, positive }), children: message })), multi && Array.isArray(value) && value.length > 0 && (jsx(SelectedTagsWrapper, { children: jsx(MultipleValue, { options: selectedItems, onRemove: handleOptionRemove }) })), isOpen && (jsx(Portal, { portal: portal, children: jsx(DivDropdownMenuSC, { ref: setPopperElement, style: {
73777
73773
  ...styles.popper,
73778
73774
  width: referenceElement?.offsetWidth,