Skip to content

Commit

Permalink
preserve selection state when updating cursor position (#5204)
Browse files Browse the repository at this point in the history
Co-authored-by: Soroush <hatpick@gmail.com>
Co-authored-by: Chris Whitten <christopher.whitten@microsoft.com>
  • Loading branch information
3 people authored Dec 8, 2020
1 parent 8bdfc4a commit c9ae8b4
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const StringField: React.FC<FieldProps<string>> = function StringField(pr

useEffect(() => {
if (cursorPosition !== undefined && cursorPosition > -1 && textFieldRef.current) {
textFieldRef.current.setSelectionRange(cursorPosition, cursorPosition);
textFieldRef.current.setSelectionRange(cursorPosition, textFieldRef.current.selectionEnd || cursorPosition);
}
}, [cursorPosition]);

Expand Down

0 comments on commit c9ae8b4

Please sign in to comment.