From 105a93469f54195368ee2ae96c8d0bd1d5b48ff3 Mon Sep 17 00:00:00 2001 From: DS Boyce <260543580+ds-boyce@users.noreply.github.com> Date: Thu, 11 Jun 2026 11:06:39 -0700 Subject: [PATCH] Fix cursor position when editing a group chat name (#10872) --- .../Messages/ConversationSettings/index.tsx | 18 ++++++++++-------- .../Messages/ConversationSettings/prompts.tsx | 10 +++++++++- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/screens/Messages/ConversationSettings/index.tsx b/src/screens/Messages/ConversationSettings/index.tsx index 9d3fdbde05..5576f28674 100644 --- a/src/screens/Messages/ConversationSettings/index.tsx +++ b/src/screens/Messages/ConversationSettings/index.tsx @@ -347,6 +347,13 @@ function SettingsHeader({ const groupName = convo.details.name const [newGroupName, setNewGroupName] = useState(groupName) + const [editNameInputKey, setEditNameInputKey] = useState(0) + + const openEditNamePrompt = () => { + setNewGroupName(groupName) + setEditNameInputKey(k => k + 1) + editNamePrompt.open() + } const lockStatus = convo.details.lockStatus @@ -485,10 +492,7 @@ function SettingsHeader({ accessibilityRole="button" accessibilityHint={l`Edit this group chat’s name`} hitSlop={HITSLOP_10} - onPress={() => { - setNewGroupName(groupName) - editNamePrompt.open() - }}> + onPress={openEditNamePrompt}> {groupNameComponent} ) : ( @@ -538,10 +542,7 @@ function SettingsHeader({ icon={EditIcon} label={l`Edit this group chat’s name`} text={l`Edit name`} - onPress={() => { - setNewGroupName(groupName) - editNamePrompt.open() - }} + onPress={openEditNamePrompt} /> ) : null} {isJoinLinkEnabled ? ( @@ -597,6 +598,7 @@ function SettingsHeader({ editGroupName({name: newGroupName})} /> diff --git a/src/screens/Messages/ConversationSettings/prompts.tsx b/src/screens/Messages/ConversationSettings/prompts.tsx index 23d7c4f333..84c1a1bea7 100644 --- a/src/screens/Messages/ConversationSettings/prompts.tsx +++ b/src/screens/Messages/ConversationSettings/prompts.tsx @@ -12,11 +12,18 @@ import {Text} from '#/components/Typography' export function EditNamePrompt({ control, value, + inputKey, onChangeText, onConfirm, }: { control: Dialog.DialogOuterProps['control'] value: string + /** + * Bump this whenever the prompt is opened to remount the (uncontrolled) + * input and reseed it from `value`. Required because the native bottom sheet + * keeps its children mounted across opens. + */ + inputKey: number onChangeText: (value: string) => void onConfirm: () => void }) { @@ -38,9 +45,10 @@ export function EditNamePrompt({