From e140148492ce9564dc2434651a82caafa4af9286 Mon Sep 17 00:00:00 2001 From: dhairyasenjaliya Date: Wed, 2 Aug 2023 12:07:41 +0530 Subject: [PATCH 1/3] Introduce label props to statePicker & stateSelectorModal --- src/components/StatePicker/StateSelectorModal.js | 10 +++++++--- src/components/StatePicker/index.js | 9 +++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/components/StatePicker/StateSelectorModal.js b/src/components/StatePicker/StateSelectorModal.js index 4497eab72de8..1c976349ed42 100644 --- a/src/components/StatePicker/StateSelectorModal.js +++ b/src/components/StatePicker/StateSelectorModal.js @@ -25,12 +25,16 @@ const propTypes = { /** Function to call when the user types in the search input */ setSearchValue: PropTypes.func.isRequired, + + /** Label to display on field*/ + label: PropTypes.string, }; const defaultProps = { currentState: '', onClose: () => {}, onStateSelected: () => {}, + label: '', }; function filterOptions(searchValue, data) { @@ -42,7 +46,7 @@ function filterOptions(searchValue, data) { return _.filter(data, (country) => country.text.toLowerCase().includes(searchValue.toLowerCase())); } -function StateSelectorModal({currentState, isVisible, onClose, onStateSelected, searchValue, setSearchValue}) { +function StateSelectorModal({currentState, isVisible, onClose, onStateSelected, searchValue, setSearchValue, label}) { const {translate} = useLocalize(); const countryStates = useMemo( @@ -69,13 +73,13 @@ function StateSelectorModal({currentState, isVisible, onClose, onStateSelected, useNativeDriver > {}, + label: '', }; -function StatePicker({value, errorText, onInputChange, forwardedRef}) { +function StatePicker({value, errorText, onInputChange, forwardedRef, label}) { const {translate} = useLocalize(); const allStates = translate('allStates'); const [isPickerVisible, setIsPickerVisible] = useState(false); @@ -61,7 +65,7 @@ function StatePicker({value, errorText, onInputChange, forwardedRef}) { ref={forwardedRef} shouldShowRightIcon title={title} - description={translate('common.state')} + description={label || translate('common.state')} descriptionTextStyle={descStyle} onPress={showPickerModal} /> @@ -75,6 +79,7 @@ function StatePicker({value, errorText, onInputChange, forwardedRef}) { onStateSelected={updateStateInput} searchValue={searchValue} setSearchValue={setSearchValue} + label={label} /> ); From 0df0560f8cbb05ba561a1940fa9935fe8d8db939 Mon Sep 17 00:00:00 2001 From: dhairyasenjaliya Date: Wed, 2 Aug 2023 13:03:25 +0530 Subject: [PATCH 2/3] lint fix --- src/components/StatePicker/StateSelectorModal.js | 2 +- src/components/StatePicker/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/StatePicker/StateSelectorModal.js b/src/components/StatePicker/StateSelectorModal.js index 1c976349ed42..aa430e94e445 100644 --- a/src/components/StatePicker/StateSelectorModal.js +++ b/src/components/StatePicker/StateSelectorModal.js @@ -26,7 +26,7 @@ const propTypes = { /** Function to call when the user types in the search input */ setSearchValue: PropTypes.func.isRequired, - /** Label to display on field*/ + /** Label to display on field */ label: PropTypes.string, }; diff --git a/src/components/StatePicker/index.js b/src/components/StatePicker/index.js index d3a0dd7d30fc..3b81e46afea1 100644 --- a/src/components/StatePicker/index.js +++ b/src/components/StatePicker/index.js @@ -21,7 +21,7 @@ const propTypes = { /** A ref to forward to MenuItemWithTopDescription */ forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({current: PropTypes.instanceOf(React.Component)})]), - /** Label to display on field*/ + /** Label to display on field */ label: PropTypes.string, }; From b80fc6af3027ea95eab9985fcc0196490e354026 Mon Sep 17 00:00:00 2001 From: dhairyasenjaliya Date: Wed, 2 Aug 2023 17:31:45 +0530 Subject: [PATCH 3/3] Added undefined default label value --- src/components/StatePicker/StateSelectorModal.js | 2 +- src/components/StatePicker/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/StatePicker/StateSelectorModal.js b/src/components/StatePicker/StateSelectorModal.js index aa430e94e445..5bbd2363c4b3 100644 --- a/src/components/StatePicker/StateSelectorModal.js +++ b/src/components/StatePicker/StateSelectorModal.js @@ -34,7 +34,7 @@ const defaultProps = { currentState: '', onClose: () => {}, onStateSelected: () => {}, - label: '', + label: undefined, }; function filterOptions(searchValue, data) { diff --git a/src/components/StatePicker/index.js b/src/components/StatePicker/index.js index 3b81e46afea1..22f0d9936186 100644 --- a/src/components/StatePicker/index.js +++ b/src/components/StatePicker/index.js @@ -30,7 +30,7 @@ const defaultProps = { forwardedRef: undefined, errorText: '', onInputChange: () => {}, - label: '', + label: undefined, }; function StatePicker({value, errorText, onInputChange, forwardedRef, label}) {