Skip to content

Commit

Permalink
Merge pull request #25456 from Nikhil-Vats/25413-fix_cursor_position
Browse files Browse the repository at this point in the history
Fix cursor shifting to end while editing messages
  • Loading branch information
neil-marcellini authored Aug 18, 2023
2 parents 0c35910 + b5bfc3e commit d4e05e3
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/components/Composer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,20 +199,22 @@ function Composer({
setValueBeforeCaret(event.target.value.slice(0, event.nativeEvent.selection.start));
setCaretContent(getNextChars(value, event.nativeEvent.selection.start));
});
const selectionValue = {
start: event.nativeEvent.selection.start,
end: event.nativeEvent.selection.end,
positionX: textRef.current.offsetLeft - CONST.SPACE_CHARACTER_WIDTH,
positionY: textRef.current.offsetTop,
};
onSelectionChange({
nativeEvent: {
selection: selectionValue,
},
});
setSelection(selectionValue);
} else {
onSelectionChange(event);
setSelection(event.nativeEvent.selection);
}

const selectionValue = {
start: event.nativeEvent.selection.start,
end: event.nativeEvent.selection.end,
positionX: textRef.current.offsetLeft - CONST.SPACE_CHARACTER_WIDTH,
positionY: textRef.current.offsetTop,
};
onSelectionChange({
nativeEvent: {
selection: selectionValue,
},
});
setSelection(selectionValue);
};

/**
Expand Down

0 comments on commit d4e05e3

Please sign in to comment.