Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed sor selection issue fix #1090

Merged
merged 5 commits into from
Jul 17, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const CustomSelectWidget = (props) => {
() => optionsList.map((e) => ({ label: t(Digit.Utils.locale.getTransformedLocale(`${schemaCode}_${e?.label}`)), value: e.value })),
[optionsList, schemaCode, data]
);
const [formattedOptions2, setFormattedOptions2] = useState([]);
const [limitedOptions, setLimitedOptions] = useState([]);
const [selectedDetails, setSelectedDetails] = useState(null);
const [showDetails, setShowDetails] = useState(null);
Expand All @@ -103,13 +104,13 @@ const CustomSelectWidget = (props) => {
<components.MenuList {...props}>{props.children}</components.MenuList>
<div className="link-container">
<div onClick={handleSeeAll} className="view-all-link">
View All
{t("VIEW_ALL")}
</div>
</div>
</div>
);
};
const selectedOption = formattedOptions?.filter((obj) => (multiple ? value?.includes(obj.value) : obj.value == value));
const selectedOption = formattedOptions2?.filter((obj) => (multiple ? value?.includes(obj.value) : obj.value == value));
const handleChange = (selectedValue) => {
setShowTooltipFlag(true);
setIsSelect(true);
Expand All @@ -130,7 +131,15 @@ const CustomSelectWidget = (props) => {
setIsSeeAll(true);
}
setSelectedDetails(mainData?.filter((obj) => (multiple ? value?.includes(obj.uniqueIdentifier) : obj.uniqueIdentifier == value)));
}, [formattedOptions, optionsLimit]);

// Update formattedOptions2
useEffect(() => {
if (value && !formattedOptions.some(option => option.value === value)) {
setFormattedOptions2(prevOptions => [...prevOptions, { value, label: `${schemaCode}_${value}` }]);
}
}, [value, formattedOptions]);

}, [formattedOptions, optionsLimit,value]);
const onClickSelect = (selectedValue) => {
selectedValue = { ...selectedValue, value: selectedValue.uniqueIdentifier, label: selectedValue.description };
onChange(selectedValue.uniqueIdentifier);
Expand Down Expand Up @@ -183,7 +192,7 @@ const CustomSelectWidget = (props) => {
<Select
className="form-control form-select"
classNamePrefix="digit"
options={data ? limitedOptions : formattedOptions}
options={data ? limitedOptions : formattedOptions2}
isDisabled={disabled || readonly}
placeholder={placeholder}
onBlur={onBlur}
Expand Down