From 8f2c16a63a103070efc2ac824a10ea889a3fc360 Mon Sep 17 00:00:00 2001 From: Angela Zheng <92692008+AngelaZQ1@users.noreply.github.com> Date: Fri, 9 Feb 2024 11:44:01 -0500 Subject: [PATCH] Select use placeholder (#705) * use placeholder, change select border color * update select colors * remove dropdown indicator color * remove styles --- packages/frontend/components/Form/Select.tsx | 20 +++++++------------ .../frontend/components/Plan/AddPlanModal.tsx | 4 ++-- .../components/Plan/EditPlanModal.tsx | 4 ++-- .../Plan/PlanConcentrationsSelect.tsx | 4 ++-- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/packages/frontend/components/Form/Select.tsx b/packages/frontend/components/Form/Select.tsx index cb9806404..223f5e22b 100644 --- a/packages/frontend/components/Form/Select.tsx +++ b/packages/frontend/components/Form/Select.tsx @@ -25,8 +25,8 @@ type PlanSelectProps = { /** Are the field values numbers. */ isNumeric?: boolean; isSearchable?: boolean; - /** An option in the select dropdown that indicates "no selection". */ - noValueOptionLabel?: string; + /** The default text shown in the input box. */ + placeholder?: string; /** Fuzzy options to use */ useFuzzySearch?: boolean; }; @@ -41,7 +41,7 @@ export const PlanSelect: React.FC = ({ rules, isNumeric, isSearchable, - noValueOptionLabel, + placeholder, useFuzzySearch, }) => { const filterOptions = useFuzzySearch @@ -73,12 +73,6 @@ export const PlanSelect: React.FC = ({ label: val, })); - let noValueOption; - if (noValueOptionLabel) { - noValueOption = { value: null, label: noValueOptionLabel }; - selectOptions.unshift(noValueOption); - } - const onChange = (option: any) => { let val = option ? option.value : null; onChangeSideEffect && onChangeSideEffect(val); @@ -94,9 +88,9 @@ export const PlanSelect: React.FC = ({ if (isNumeric) { selectedValue = value ? value.toString() : null; } - const selectedOption = - selectOptions.find((option: any) => option.value === selectedValue) ?? - noValueOption; + const selectedOption = selectOptions.find( + (option: any) => option.value === selectedValue + ); return ( @@ -113,7 +107,7 @@ export const PlanSelect: React.FC = ({ onChange={onChange} value={selectedOption} isSearchable={isSearchable} - defaultValue={noValueOption} + placeholder={placeholder} filterOption={filterOptions} {...fieldRest} /> diff --git a/packages/frontend/components/Plan/AddPlanModal.tsx b/packages/frontend/components/Plan/AddPlanModal.tsx index be612eed9..7f6163847 100644 --- a/packages/frontend/components/Plan/AddPlanModal.tsx +++ b/packages/frontend/components/Plan/AddPlanModal.tsx @@ -199,7 +199,7 @@ export const AddPlanModal: React.FC = ({ <> = ({ /> = ({ plan }) => { <> = ({ plan }) => { />