InlineTextArea: auto-select all on edit

Except for the Fusion instructions, and the Compact
This commit is contained in:
Enrico Ros
2025-06-13 11:11:36 -07:00
parent 0635edbfff
commit 4e1d7f0b82
3 changed files with 8 additions and 1 deletions
+6
View File
@@ -17,6 +17,7 @@ export function InlineTextarea(props: {
centerText?: boolean,
minRows?: number,
syncWithInitialText?: boolean, // optional. if set, the text will be reset to initialText when the prop changes
selectAllOnFocus?: boolean, // optional. if set to false, text won't be selected on focus (default: true)
onEdit: (text: string) => void,
onCancel?: () => void,
sx?: SxProps,
@@ -72,6 +73,11 @@ export function InlineTextarea(props: {
...(props.centerText && {
sx: { textAlign: 'center' },
}),
onFocus: (props.selectAllOnFocus === false) ? undefined : (e) => {
// Select all text when the textarea receives focus
// This is a great default behavior for all the inline text edits
e.target?.select();
},
},
}}
sx={props.sx}
+1 -1
View File
@@ -208,7 +208,7 @@ export function FlattenerModal(props: {
)}
{/* Review or Edit Text */}
{isSuccess && <InlineTextarea initialText={flattenedText} onEdit={setText} />}
{isSuccess && <InlineTextarea initialText={flattenedText} selectAllOnFocus={false} onEdit={setText} />}
</Box>}
@@ -51,6 +51,7 @@ function EditableChatInstructionPrompt(props: {
decolor
initialText={props.itemValue}
minRows={3}
selectAllOnFocus={false}
onCancel={handleEditCancel}
onEdit={handleEdit}
sx={{