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/cjs/index.js
CHANGED
|
@@ -73648,7 +73648,7 @@ const FISSelect = React.forwardRef(({ className, style, size = "md", options, va
|
|
|
73648
73648
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
73649
73649
|
const [referenceElement, setReferenceElement] = React.useState(null);
|
|
73650
73650
|
const [popperElement, setPopperElement] = React.useState(null);
|
|
73651
|
-
const
|
|
73651
|
+
const isSelectingRef = React.useRef(false);
|
|
73652
73652
|
const popperOptions = React.useMemo(() => ({
|
|
73653
73653
|
modifiers: [
|
|
73654
73654
|
{ name: "preventOverflow", options: { padding: 0, altAxis: true } },
|
|
@@ -73693,8 +73693,10 @@ const FISSelect = React.forwardRef(({ className, style, size = "md", options, va
|
|
|
73693
73693
|
}
|
|
73694
73694
|
}, [multi, value, multiDisplayText, selectedItems, displayValue]);
|
|
73695
73695
|
const handleToggle = React.useCallback(() => {
|
|
73696
|
-
if (!disabled)
|
|
73696
|
+
if (!disabled) {
|
|
73697
|
+
console.log("Toggle dropdown"); // Debug log
|
|
73697
73698
|
setIsOpen((prev) => !prev);
|
|
73699
|
+
}
|
|
73698
73700
|
}, [disabled]);
|
|
73699
73701
|
const handleOptionRemove = React.useCallback((option) => {
|
|
73700
73702
|
if (multi && Array.isArray(value)) {
|
|
@@ -73703,36 +73705,49 @@ const FISSelect = React.forwardRef(({ className, style, size = "md", options, va
|
|
|
73703
73705
|
}
|
|
73704
73706
|
}, [multi, onChange, value]);
|
|
73705
73707
|
const handleMenuChange = React.useCallback((values) => {
|
|
73706
|
-
|
|
73708
|
+
console.log("Starting selection, keeping onBlur blocked"); // Debug log
|
|
73707
73709
|
if (multi) {
|
|
73708
73710
|
onChange(values);
|
|
73709
|
-
|
|
73711
|
+
// For multi-select, allow onBlur immediately since dropdown stays open
|
|
73712
|
+
setTimeout(() => {
|
|
73713
|
+
console.log("Multi-selection complete, allowing onBlur"); // Debug log
|
|
73714
|
+
isSelectingRef.current = false;
|
|
73715
|
+
}, 50);
|
|
73710
73716
|
}
|
|
73711
73717
|
else {
|
|
73712
73718
|
if (values.length > 0) {
|
|
73713
73719
|
onChange(values[0]);
|
|
73714
73720
|
setIsOpen(false);
|
|
73715
|
-
//
|
|
73716
|
-
setTimeout(() =>
|
|
73721
|
+
// Keep blocking until value is processed
|
|
73722
|
+
setTimeout(() => {
|
|
73723
|
+
console.log("Single selection complete, allowing onBlur"); // Debug log
|
|
73724
|
+
isSelectingRef.current = false;
|
|
73725
|
+
}, 150);
|
|
73717
73726
|
}
|
|
73718
73727
|
}
|
|
73719
73728
|
}, [multi, onChange]);
|
|
73720
73729
|
const handleMenuClick = React.useCallback(() => {
|
|
73721
73730
|
if (!multi) {
|
|
73731
|
+
console.log("Menu click - closing dropdown"); // Debug log
|
|
73722
73732
|
setIsOpen(false);
|
|
73723
73733
|
}
|
|
73724
73734
|
}, [multi]);
|
|
73725
73735
|
// Handle onBlur to prevent validation flash during selection
|
|
73726
73736
|
const handleBlur = React.useCallback((event) => {
|
|
73727
|
-
//
|
|
73728
|
-
if (
|
|
73737
|
+
// Block onBlur if dropdown is open OR we're in the middle of selection
|
|
73738
|
+
if (isOpen || isSelectingRef.current) {
|
|
73739
|
+
console.log("Blocking onBlur - dropdown open or selecting:", {
|
|
73740
|
+
isOpen,
|
|
73741
|
+
isSelecting: isSelectingRef.current,
|
|
73742
|
+
}); // Debug log
|
|
73729
73743
|
return;
|
|
73730
73744
|
}
|
|
73745
|
+
console.log("Allowing onBlur to proceed"); // Debug log
|
|
73731
73746
|
// Call original onBlur if provided
|
|
73732
73747
|
if (restProps.onBlur) {
|
|
73733
73748
|
restProps.onBlur(event);
|
|
73734
73749
|
}
|
|
73735
|
-
}, [
|
|
73750
|
+
}, [isOpen, restProps]);
|
|
73736
73751
|
const menuProps = React.useMemo(() => ({
|
|
73737
73752
|
groups: options,
|
|
73738
73753
|
placeholder: placeholderSearch,
|
|
@@ -73775,12 +73790,25 @@ const FISSelect = React.forwardRef(({ className, style, size = "md", options, va
|
|
|
73775
73790
|
!referenceElement.contains(target) &&
|
|
73776
73791
|
popperElement &&
|
|
73777
73792
|
!popperElement.contains(target)) {
|
|
73793
|
+
console.log("Click outside - closing dropdown"); // Debug log
|
|
73778
73794
|
setIsOpen(false);
|
|
73779
73795
|
}
|
|
73780
73796
|
};
|
|
73781
73797
|
document.addEventListener("mousedown", handleClickOutside);
|
|
73782
73798
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
73783
73799
|
}, [isOpen, referenceElement, popperElement]);
|
|
73800
|
+
// Add delay after dropdown closes to ensure validation processes
|
|
73801
|
+
React.useEffect(() => {
|
|
73802
|
+
if (!isOpen && !multi) {
|
|
73803
|
+
// When dropdown closes, give time for value to be processed before allowing onBlur
|
|
73804
|
+
isSelectingRef.current = true;
|
|
73805
|
+
const timer = setTimeout(() => {
|
|
73806
|
+
console.log("Dropdown closed delay complete, allowing onBlur"); // Debug log
|
|
73807
|
+
isSelectingRef.current = false;
|
|
73808
|
+
}, 200);
|
|
73809
|
+
return () => clearTimeout(timer);
|
|
73810
|
+
}
|
|
73811
|
+
}, [isOpen, multi]);
|
|
73784
73812
|
return (jsxRuntime.jsxs(DivWrapperSC$1, { className: className, style: style, children: [(textLabel || iconLabel) && (jsxRuntime.jsx(FISInputLabel, { textLabel: textLabel, required: required, iconLabel: iconLabel, onClickIconLabel: onClickIconLabel })), jsxRuntime.jsx(DivInputWrapperSC, { ref: setReferenceElement, onClick: handleToggle, "$hasValue": !!value, children: jsxRuntime.jsx(FISSelectItem, { ...restProps, onBlur: handleBlur, ref: ref, size: size, placeholder: placeholder, iconSuffix: isOpen ? jsxRuntime.jsx(ArrowUpIcon, {}) : jsxRuntime.jsx(ArrowDownIcon, {}), value: computedDisplayValue, disabled: disabled, activeDropdown: isOpen, negative: negative }) }), message && (jsxRuntime.jsx(SpanHintSC$3, { className: classNames({ disabled, negative, positive }), children: message })), multi && Array.isArray(value) && value.length > 0 && (jsxRuntime.jsx(SelectedTagsWrapper, { children: jsxRuntime.jsx(MultipleValue, { options: selectedItems, onRemove: handleOptionRemove }) })), isOpen && (jsxRuntime.jsx(Portal, { portal: portal, children: jsxRuntime.jsx(DivDropdownMenuSC, { ref: setPopperElement, style: {
|
|
73785
73813
|
...styles.popper,
|
|
73786
73814
|
width: referenceElement?.offsetWidth,
|