Skip to content

Commit ad3472f

Browse files
committed
Select entire content and move cursor to end when focusing PromptField input
1 parent a8454fa commit ad3472f

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎packages/ui/src/components/editor/panel/PromptField/hooks/use-handlers.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ export const use_handlers = (
126126
useEffect(() => {
127127
if (params.input_ref.current && !props.missing_configuration) {
128128
params.input_ref.current.focus()
129+
const selection = window.getSelection()
130+
if (selection) {
131+
const range = document.createRange()
132+
range.selectNodeContents(params.input_ref.current)
133+
range.collapse(false)
134+
selection.removeAllRanges()
135+
selection.addRange(range)
136+
}
129137
}
130138
}, [props.focus_key, props.missing_configuration])
131139

0 commit comments

Comments
 (0)