not change position after inserting file

This commit is contained in:
2023-05-04 01:37:29 +08:00
parent f255f46967
commit 19769ad0d8
4 changed files with 20 additions and 13 deletions

View File

@@ -362,9 +362,16 @@ export class SafeTextarea extends Component {
set(text) {
this.change_callback(text);
this.setState({
text: text,
});
let currPos = this.area_ref.current.selectionStart;
this.setState(
{
text: text,
},
() => {
this.area_ref.current.setSelectionRange(currPos, currPos);
this.area_ref.current.focus();
},
);
}
get() {