servo/components
elomscansio 30a2a89d16
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>
2025-03-26 18:37:48 +00:00
..
allocator chore: Move unsafe operations in unsafe functions to unsafe blocks (#36017) 2025-03-18 06:19:35 +00:00
background_hang_monitor chore: Move unsafe operations in unsafe functions to unsafe blocks (#36017) 2025-03-18 06:19:35 +00:00
bluetooth Migrate to the 2024 edition (#35755) 2025-03-13 10:28:11 +00:00
canvas Add Path2D (#35783) 2025-03-26 12:12:44 +00:00
compositing compositor: Remove the script channel from the compositor (#36089) 2025-03-23 11:19:27 +00:00
config Hide servo internal shadow roots from the inspector by default (#35958) 2025-03-13 13:08:24 +00:00
constellation feat(notification): add EmbedderMsg::ShowNotification (#36055) 2025-03-24 13:01:36 +00:00
deny_public_fields Add rust-version to all Cargo.toml files (#33483) 2024-09-17 16:39:07 +00:00
devtools devtools: refactor network related (#36093) 2025-03-22 14:46:57 +00:00
dom_struct script: Feature-gate all crown support. (#35055) 2025-01-18 21:36:15 +00:00
domobject_derive Update rustfmt to the 2024 style edition (#35764) 2025-03-03 11:26:53 +00:00
fonts Upgrade to Stylo e941241 (#36120) 2025-03-25 10:45:40 +00:00
geometry servoshell: Allow overriding screen resolution with a command-line argument (#34038) 2024-10-30 11:54:13 +00:00
hyper_serde Update rustfmt to the 2024 style edition (#35764) 2025-03-03 11:26:53 +00:00
jstraceable_derive Add rust-version to all Cargo.toml files (#33483) 2024-09-17 16:39:07 +00:00
layout_2020 script: Eliminate PseudoElementType (#36146) 2025-03-26 08:33:12 +00:00
layout_thread_2020 Create a constellation_traits crate (#36088) 2025-03-22 15:49:08 +00:00
malloc_size_of Cleanup Stylo dependencies (#36046) 2025-03-19 08:53:26 +00:00
media Update rustfmt to the 2024 style edition (#35764) 2025-03-03 11:26:53 +00:00
metrics metrics: Simplify ProgressiveWebMetrics (#35985) 2025-03-21 14:55:00 +00:00
net fix: does_settings_prohibit_mixed_security_contexts typo (#36135) 2025-03-24 18:39:45 +00:00
pixels pixels: Extend Image to allow for multiple frames (#36058) 2025-03-21 10:32:14 +00:00
profile Use strum to iterate through enum variants and get their names (#35933) 2025-03-13 12:00:31 +00:00
rand Migrate to the 2024 edition (#35755) 2025-03-13 10:28:11 +00:00
range Add rust-version to all Cargo.toml files (#33483) 2024-09-17 16:39:07 +00:00
script Fix Backspace deleting entire previous line in <textarea> (#36112) 2025-03-26 18:37:48 +00:00
script_bindings Add Path2D (#35783) 2025-03-26 12:12:44 +00:00
servo feat(notification): add EmbedderMsg::ShowNotification (#36055) 2025-03-24 13:01:36 +00:00
shared Add Path2D (#35783) 2025-03-26 12:12:44 +00:00
timers Update rustfmt to the 2024 style edition (#35764) 2025-03-03 11:26:53 +00:00
url Eliminate to_shmem dependency from servo_url (#35897) 2025-03-11 00:33:39 +00:00
webdriver_server Create a constellation_traits crate (#36088) 2025-03-22 15:49:08 +00:00
webgpu webgpu: leverage routed_promise in calls returning promises (#35859) 2025-03-23 18:52:46 +00:00
webxr Update rustfmt to the 2024 style edition (#35764) 2025-03-03 11:26:53 +00:00