fis-component 0.0.92 → 0.0.94
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/cjs/index.js +37 -9
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +37 -9
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -73628,7 +73628,7 @@ const FISSelect = forwardRef(({ className, style, size = "md", options, value, d
|
|
|
73628
73628
|
const [isOpen, setIsOpen] = useState(false);
|
|
73629
73629
|
const [referenceElement, setReferenceElement] = useState(null);
|
|
73630
73630
|
const [popperElement, setPopperElement] = useState(null);
|
|
73631
|
-
const
|
|
73631
|
+
const isSelectingRef = useRef(false);
|
|
73632
73632
|
const popperOptions = useMemo$1(() => ({
|
|
73633
73633
|
modifiers: [
|
|
73634
73634
|
{ name: "preventOverflow", options: { padding: 0, altAxis: true } },
|
|
@@ -73673,8 +73673,10 @@ 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
|
+
console.log("Toggle dropdown"); // Debug log
|
|
73677
73678
|
setIsOpen((prev) => !prev);
|
|
73679
|
+
}
|
|
73678
73680
|
}, [disabled]);
|
|
73679
73681
|
const handleOptionRemove = useCallback((option) => {
|
|
73680
73682
|
if (multi && Array.isArray(value)) {
|
|
@@ -73683,36 +73685,49 @@ const FISSelect = forwardRef(({ className, style, size = "md", options, value, d
|
|
|
73683
73685
|
}
|
|
73684
73686
|
}, [multi, onChange, value]);
|
|
73685
73687
|
const handleMenuChange = useCallback((values) => {
|
|
73686
|
-
|
|
73688
|
+
console.log("Starting selection, keeping onBlur blocked"); // Debug log
|
|
73687
73689
|
if (multi) {
|
|
73688
73690
|
onChange(values);
|
|
73689
|
-
|
|
73691
|
+
// For multi-select, allow onBlur immediately since dropdown stays open
|
|
73692
|
+
setTimeout(() => {
|
|
73693
|
+
console.log("Multi-selection complete, allowing onBlur"); // Debug log
|
|
73694
|
+
isSelectingRef.current = false;
|
|
73695
|
+
}, 50);
|
|
73690
73696
|
}
|
|
73691
73697
|
else {
|
|
73692
73698
|
if (values.length > 0) {
|
|
73693
73699
|
onChange(values[0]);
|
|
73694
73700
|
setIsOpen(false);
|
|
73695
|
-
//
|
|
73696
|
-
setTimeout(() =>
|
|
73701
|
+
// Keep blocking until value is processed
|
|
73702
|
+
setTimeout(() => {
|
|
73703
|
+
console.log("Single selection complete, allowing onBlur"); // Debug log
|
|
73704
|
+
isSelectingRef.current = false;
|
|
73705
|
+
}, 150);
|
|
73697
73706
|
}
|
|
73698
73707
|
}
|
|
73699
73708
|
}, [multi, onChange]);
|
|
73700
73709
|
const handleMenuClick = useCallback(() => {
|
|
73701
73710
|
if (!multi) {
|
|
73711
|
+
console.log("Menu click - closing dropdown"); // Debug log
|
|
73702
73712
|
setIsOpen(false);
|
|
73703
73713
|
}
|
|
73704
73714
|
}, [multi]);
|
|
73705
73715
|
// Handle onBlur to prevent validation flash during selection
|
|
73706
73716
|
const handleBlur = useCallback((event) => {
|
|
73707
|
-
//
|
|
73708
|
-
if (
|
|
73717
|
+
// Block onBlur if dropdown is open OR we're in the middle of selection
|
|
73718
|
+
if (isOpen || isSelectingRef.current) {
|
|
73719
|
+
console.log("Blocking onBlur - dropdown open or selecting:", {
|
|
73720
|
+
isOpen,
|
|
73721
|
+
isSelecting: isSelectingRef.current,
|
|
73722
|
+
}); // Debug log
|
|
73709
73723
|
return;
|
|
73710
73724
|
}
|
|
73725
|
+
console.log("Allowing onBlur to proceed"); // Debug log
|
|
73711
73726
|
// Call original onBlur if provided
|
|
73712
73727
|
if (restProps.onBlur) {
|
|
73713
73728
|
restProps.onBlur(event);
|
|
73714
73729
|
}
|
|
73715
|
-
}, [
|
|
73730
|
+
}, [isOpen, restProps]);
|
|
73716
73731
|
const menuProps = useMemo$1(() => ({
|
|
73717
73732
|
groups: options,
|
|
73718
73733
|
placeholder: placeholderSearch,
|
|
@@ -73755,12 +73770,25 @@ const FISSelect = forwardRef(({ className, style, size = "md", options, value, d
|
|
|
73755
73770
|
!referenceElement.contains(target) &&
|
|
73756
73771
|
popperElement &&
|
|
73757
73772
|
!popperElement.contains(target)) {
|
|
73773
|
+
console.log("Click outside - closing dropdown"); // Debug log
|
|
73758
73774
|
setIsOpen(false);
|
|
73759
73775
|
}
|
|
73760
73776
|
};
|
|
73761
73777
|
document.addEventListener("mousedown", handleClickOutside);
|
|
73762
73778
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
73763
73779
|
}, [isOpen, referenceElement, popperElement]);
|
|
73780
|
+
// Add delay after dropdown closes to ensure validation processes
|
|
73781
|
+
useEffect(() => {
|
|
73782
|
+
if (!isOpen && !multi) {
|
|
73783
|
+
// When dropdown closes, give time for value to be processed before allowing onBlur
|
|
73784
|
+
isSelectingRef.current = true;
|
|
73785
|
+
const timer = setTimeout(() => {
|
|
73786
|
+
console.log("Dropdown closed delay complete, allowing onBlur"); // Debug log
|
|
73787
|
+
isSelectingRef.current = false;
|
|
73788
|
+
}, 200);
|
|
73789
|
+
return () => clearTimeout(timer);
|
|
73790
|
+
}
|
|
73791
|
+
}, [isOpen, multi]);
|
|
73764
73792
|
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: {
|
|
73765
73793
|
...styles.popper,
|
|
73766
73794
|
width: referenceElement?.offsetWidth,
|