feat: Improve text edit popup focus and cursor placement
This commit is contained in:
parent
0c13e708b9
commit
3383280726
@ -51,6 +51,17 @@ const PopupContainer: React.FC<Props> = ({ text, textareaProps, modalProps, reso
|
|||||||
setTimeout(resizeTextArea, 0)
|
setTimeout(resizeTextArea, 0)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
const handleAfterOpenChange = (visible: boolean) => {
|
||||||
|
if (visible) {
|
||||||
|
const textArea = textareaRef.current?.resizableTextArea?.textArea
|
||||||
|
if (textArea) {
|
||||||
|
textArea.focus()
|
||||||
|
const length = textArea.value.length
|
||||||
|
textArea.setSelectionRange(length, length)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TextEditPopup.hide = onCancel
|
TextEditPopup.hide = onCancel
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -65,6 +76,7 @@ const PopupContainer: React.FC<Props> = ({ text, textareaProps, modalProps, reso
|
|||||||
onOk={onOk}
|
onOk={onOk}
|
||||||
onCancel={onCancel}
|
onCancel={onCancel}
|
||||||
afterClose={onClose}
|
afterClose={onClose}
|
||||||
|
afterOpenChange={handleAfterOpenChange}
|
||||||
centered>
|
centered>
|
||||||
<TextArea
|
<TextArea
|
||||||
ref={textareaRef}
|
ref={textareaRef}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user