feat: update position of cursor when navigating input history with arrow keys to the end of the text (#255)
Updated the position of the cursor on the user input box to be at the end of the text when the user uses the arrow keys to navigate through the input history in order to better match the behavior of a terminal.
This commit is contained in:
parent
0a2e416b7a
commit
ed49daca32
1 changed files with 5 additions and 2 deletions
|
|
@ -105,8 +105,11 @@ function TextInput({
|
|||
}
|
||||
|
||||
const newValue = originalValue || "";
|
||||
|
||||
if (previousState.cursorOffset > newValue.length - 1) {
|
||||
// Sets the cursor to the end of the line if the value is empty or the cursor is at the end of the line.
|
||||
if (
|
||||
previousState.cursorOffset === 0 ||
|
||||
previousState.cursorOffset > newValue.length - 1
|
||||
) {
|
||||
return {
|
||||
cursorOffset: newValue.length,
|
||||
cursorWidth: 0,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue