From 3bd1f78ea3c67304addda474c4adf1bd2428208d Mon Sep 17 00:00:00 2001 From: devanshu052000 Date: Mon, 28 Apr 2025 16:02:45 +0530 Subject: [PATCH] Fix: Select all option should not get exposed anywhere. --- .../Components/MultiselectV2/CustomValueContainer.jsx | 6 +++++- .../src/Editor/Components/MultiselectV2/MultiselectV2.jsx | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/Editor/Components/MultiselectV2/CustomValueContainer.jsx b/frontend/src/Editor/Components/MultiselectV2/CustomValueContainer.jsx index 62db4a2a0d..d167818036 100644 --- a/frontend/src/Editor/Components/MultiselectV2/CustomValueContainer.jsx +++ b/frontend/src/Editor/Components/MultiselectV2/CustomValueContainer.jsx @@ -6,7 +6,11 @@ import './multiselectV2.scss'; const CustomValueContainer = ({ children, ...props }) => { const selectProps = props.selectProps; - const values = Array.isArray(selectProps?.value) && selectProps?.value?.map((option) => option.label); + const values = + Array.isArray(selectProps?.value) && + selectProps?.value + ?.filter((option) => option.value !== 'multiselect-custom-menulist-select-all') //Remove the Select all option if selected + ?.map((option) => option.label); const isAllOptionsSelected = selectProps?.value.length === selectProps.options.length; const valueContainerWidth = selectProps?.containerRef?.current?.offsetWidth; // eslint-disable-next-line import/namespace diff --git a/frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx b/frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx index db44bc15f8..78b7c79552 100644 --- a/frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx +++ b/frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx @@ -146,7 +146,7 @@ export const MultiselectV2 = ({ if (action.option?.value === SELECT_ALL) { // Case 1 - If select all is selected if (action.action === 'select-option') { - setInputValue(modifiedSelectOptions); + setInputValue(selectOptions); } else { setInputValue([]); } @@ -155,7 +155,7 @@ export const MultiselectV2 = ({ setInputValue(items.filter((item) => item.value !== SELECT_ALL)); } else if (selectOptions?.length === items?.length) { // Case 3 - If all options are selected except select all - setInputValue(modifiedSelectOptions); + setInputValue(selectOptions); } else { // Case 4 - Normal selection setInputValue(items); @@ -503,7 +503,7 @@ export const MultiselectV2 = ({ ref={selectRef} menuId={id} isDisabled={isMultiSelectDisabled} - value={selected} + value={selectOptions?.length === selected?.length ? modifiedSelectOptions : selected} onChange={onChangeHandler} options={modifiedSelectOptions} styles={customStyles}