diff options
author | elomscansio <163124154+elomscansio@users.noreply.github.com> | 2025-03-26 19:37:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-26 18:37:48 +0000 |
commit | 30a2a89d160dd40da6344a554ad285bb8d3d5e14 (patch) | |
tree | 7dd1390189dc0cd77330927650df64f8b500dbcf /components/script/dom/domexception.rs | |
parent | 4f33f31c8617271696be8a582788c94b3fe2d847 (diff) | |
download | servo-30a2a89d160dd40da6344a554ad285bb8d3d5e14.tar.gz servo-30a2a89d160dd40da6344a554ad285bb8d3d5e14.zip |
Fix Backspace deleting entire previous line in `<textarea>` (#36112)
* test(textinput): Add test for backspace at beginning of line in textarea
Introduce a test to reproduce and verify the fix for backspacing at the
beginning of a line in a multiline textarea. This ensures that pressing
Backspace when the cursor is at the start of a line correctly removes the
newline without deleting the entire previous line’s content.
Related to: #27523
Signed-off-by: Emmanuel Elom <elomemmanuel007@gmail.com>
* fix(textinput): Preserve selection origin when adjusting vertical position
Fixes an issue where pressing Backspace at the beginning of a line in a
textarea incorrectly deleted the entire previous line's content. This happened
because `self.adjust_vertical(-1, select)` modified `selection_origin` and
`edit_point`, but `selection_origin` was not restored before performing the
horizontal adjustment. As a result, `self.selection_start()` and
`self.selection_end()` were inconsistent, leading to `replace_operation`
erasing the entire line.
Now, we temporarily store `selection_origin` before adjusting vertical
position and restore it afterward to ensure proper cursor and selection
behavior.
Fixes: #27523
Signed-off-by: Emmanuel Elom <elomemmanuel007@gmail.com>
---------
Signed-off-by: Emmanuel Elom <elomemmanuel007@gmail.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
Diffstat (limited to 'components/script/dom/domexception.rs')
0 files changed, 0 insertions, 0 deletions