mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Fix clearing the selection when value is changed
The implementation of adjust_horizontal_to_limit() is written with UI in mind. As such, when there's a selection and we "adjust horizontal", the selection will be cleared and the cursor will and up at the start/end of the previous selection. This is what happens when you have a selection and you press an arrow key on your keyboard, but it isn't the behaviour we want when programmatically changing the value. Instead, we need to first clear the selection, and then move the cursor to the end. (We also need to reset the selection direction when clearing the selection.)
This commit is contained in:
parent
02883a6f54
commit
648bfbeb02
4 changed files with 11 additions and 25 deletions
|
@ -35,7 +35,7 @@ use std::default::Default;
|
|||
use std::ops::Range;
|
||||
use style::attr::AttrValue;
|
||||
use style::element_state::ElementState;
|
||||
use textinput::{Direction, KeyReaction, Lines, Selection, SelectionDirection, TextInput};
|
||||
use textinput::{KeyReaction, Lines, SelectionDirection, TextInput};
|
||||
|
||||
#[dom_struct]
|
||||
pub struct HTMLTextAreaElement {
|
||||
|
@ -257,7 +257,7 @@ impl HTMLTextAreaElementMethods for HTMLTextAreaElement {
|
|||
|
||||
if old_value != textinput.get_content() {
|
||||
// Step 4
|
||||
textinput.adjust_horizontal_to_limit(Direction::Forward, Selection::NotSelected);
|
||||
textinput.clear_selection_to_limit();
|
||||
} else {
|
||||
textinput.selection_origin = old_selection;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue