From c8c86a33f8ddbb35f2d814969a339567ce1a965d Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Fri, 31 May 2024 17:36:12 +0530 Subject: [PATCH] chore: added a prop to render default state conditionally (#4669) --- web/components/dropdowns/state.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/web/components/dropdowns/state.tsx b/web/components/dropdowns/state.tsx index c6f54f993..7408a8d16 100644 --- a/web/components/dropdowns/state.tsx +++ b/web/components/dropdowns/state.tsx @@ -24,7 +24,8 @@ type Props = TDropdownProps & { onChange: (val: string) => void; onClose?: () => void; projectId: string; - value: string; + showDefaultState?: boolean; + value: string | undefined; }; export const StateDropdown: React.FC = observer((props) => { @@ -42,6 +43,7 @@ export const StateDropdown: React.FC = observer((props) => { onClose, placement, projectId, + showDefaultState = true, showTooltip = false, tabIndex, value, @@ -72,8 +74,8 @@ export const StateDropdown: React.FC = observer((props) => { const { workspaceSlug } = useAppRouter(); const { fetchProjectStates, getProjectStates, getStateById } = useProjectState(); const statesList = getProjectStates(projectId); - const defaultStateList = statesList?.find((state) => state.default); - const stateValue = value ? value : defaultStateList?.id; + const defaultState = statesList?.find((state) => state.default); + const stateValue = value ?? (showDefaultState ? defaultState?.id : undefined); const options = statesList?.map((state) => ({ value: state.id, @@ -170,7 +172,7 @@ export const StateDropdown: React.FC = observer((props) => { {!hideIcon && ( )}