File tree Expand file tree Collapse file tree
src/screens/Messages/ConversationSettings Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -347,6 +347,13 @@ function SettingsHeader({
347347
348348 const groupName = convo . details . name
349349 const [ newGroupName , setNewGroupName ] = useState ( groupName )
350+ const [ editNameInputKey , setEditNameInputKey ] = useState ( 0 )
351+
352+ const openEditNamePrompt = ( ) => {
353+ setNewGroupName ( groupName )
354+ setEditNameInputKey ( k => k + 1 )
355+ editNamePrompt . open ( )
356+ }
350357
351358 const lockStatus = convo . details . lockStatus
352359
@@ -485,10 +492,7 @@ function SettingsHeader({
485492 accessibilityRole = "button"
486493 accessibilityHint = { l `Edit this group chat’s name` }
487494 hitSlop = { HITSLOP_10 }
488- onPress = { ( ) => {
489- setNewGroupName ( groupName )
490- editNamePrompt . open ( )
491- } } >
495+ onPress = { openEditNamePrompt } >
492496 { groupNameComponent }
493497 </ Pressable >
494498 ) : (
@@ -538,10 +542,7 @@ function SettingsHeader({
538542 icon = { EditIcon }
539543 label = { l `Edit this group chat’s name` }
540544 text = { l `Edit name` }
541- onPress = { ( ) => {
542- setNewGroupName ( groupName )
543- editNamePrompt . open ( )
544- } }
545+ onPress = { openEditNamePrompt }
545546 />
546547 ) : null }
547548 { isJoinLinkEnabled ? (
@@ -597,6 +598,7 @@ function SettingsHeader({
597598 < EditNamePrompt
598599 control = { editNamePrompt }
599600 value = { newGroupName }
601+ inputKey = { editNameInputKey }
600602 onChangeText = { setNewGroupName }
601603 onConfirm = { ( ) => editGroupName ( { name : newGroupName } ) }
602604 />
Original file line number Diff line number Diff line change @@ -12,11 +12,18 @@ import {Text} from '#/components/Typography'
1212export function EditNamePrompt ( {
1313 control,
1414 value,
15+ inputKey,
1516 onChangeText,
1617 onConfirm,
1718} : {
1819 control : Dialog . DialogOuterProps [ 'control' ]
1920 value : string
21+ /**
22+ * Bump this whenever the prompt is opened to remount the (uncontrolled)
23+ * input and reseed it from `value`. Required because the native bottom sheet
24+ * keeps its children mounted across opens.
25+ */
26+ inputKey : number
2027 onChangeText : ( value : string ) => void
2128 onConfirm : ( ) => void
2229} ) {
@@ -38,9 +45,10 @@ export function EditNamePrompt({
3845 < View style = { [ a . my_sm ] } >
3946 < TextField . Root isInvalid = { nameTooLong } >
4047 < TextField . Input
48+ key = { inputKey }
4149 label = { l `Edit group name` }
4250 placeholder = { l `Group name` }
43- value = { value }
51+ defaultValue = { value }
4452 onChangeText = { onChangeText }
4553 returnKeyType = "done"
4654 autoCapitalize = "none"
You can’t perform that action at this time.
0 commit comments