From ce52c293a3f8f7184e7839d1c27e67892c8b6be0 Mon Sep 17 00:00:00 2001 From: Narender Vaddepelly <146728229+empro-narendervaddepelly@users.noreply.github.com> Date: Thu, 19 Jun 2025 22:40:46 +0200 Subject: [PATCH 1/2] Extended dropdown to use custom selected text --- src/components/Dropdown/index.tsx | 3 ++- src/components/Dropdown/model.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/Dropdown/index.tsx b/src/components/Dropdown/index.tsx index 2a73f2f..b8d789e 100644 --- a/src/components/Dropdown/index.tsx +++ b/src/components/Dropdown/index.tsx @@ -51,6 +51,7 @@ const DropdownComponent = React.forwardRef>( style = {}, containerStyle, placeholderStyle, + selectedText, selectedTextStyle, itemContainerStyle, itemTextStyle, @@ -460,7 +461,7 @@ const DropdownComponent = React.forwardRef>( {...selectedTextProps} > {isSelected !== null - ? _get(currentValue, labelField) + ? (selectedText ? selectedText : _get(currentValue, labelField)) : placeholder} {renderRightIcon ? ( diff --git a/src/components/Dropdown/model.ts b/src/components/Dropdown/model.ts index e4212a9..a001ce2 100644 --- a/src/components/Dropdown/model.ts +++ b/src/components/Dropdown/model.ts @@ -24,6 +24,7 @@ export interface DropdownProps { style?: StyleProp; containerStyle?: StyleProp; placeholderStyle?: StyleProp; + selectedText?: string; selectedTextStyle?: StyleProp; selectedTextProps?: TextProps; itemContainerStyle?: StyleProp; From da48471a5100c3a4f5536ca084fd47f01031f2f4 Mon Sep 17 00:00:00 2001 From: Narender Vaddepelly <146728229+empro-narendervaddepelly@users.noreply.github.com> Date: Thu, 19 Jun 2025 22:43:41 +0200 Subject: [PATCH 2/2] Update readme with selectedText option --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 647040a..436fd59 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,8 @@ yarn add react-native-element-dropdown | value | Item | No | Set default value | | placeholder | String | No | The string that will be rendered before dropdown has been selected | | placeholderStyle | TextStyle | No | Styling for text placeholder | -| selectedTextStyle | TextStyle | No | Styling for selected text | +| selectedText | TextStyle | No | Styling for selected text | +| selectedTextStyle | TextStyle | No | Custom selected text | | selectedTextProps | TextProps | No | Text Props for selected text. Ex: numberOfLines={1} | | style | ViewStyle | No | Styling for view container | | containerStyle | ViewStyle | No | Styling for list container |