mirror of
https://github.com/servo/servo.git
synced 2025-07-17 04:13:42 +01:00
textinput: position the caret at the end when selecting input (#36478)
When clicking on a text input element, we currently position the caret at the very beginning, even if there is already text present. That makes is annoying when you want to add text, and doesn't match what other browsers do. Instead, this change positions the caret at the end of the current text. Testing: Not covered by any wpt tests (rightly so I think). Signed-off-by: webbeef <me@webbeef.org>
This commit is contained in:
parent
fc2eb7bff2
commit
3c4ec17180
1 changed files with 12 additions and 6 deletions
|
@ -2647,12 +2647,18 @@ impl VirtualMethods for HTMLInputElement {
|
|||
point_in_target,
|
||||
CanGc::note(),
|
||||
);
|
||||
if let Some(i) = index {
|
||||
self.textinput.borrow_mut().set_edit_point_index(i);
|
||||
// trigger redraw
|
||||
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
|
||||
event.PreventDefault();
|
||||
}
|
||||
// Position the caret at the click position or at the end of the current
|
||||
// value.
|
||||
let edit_point_index = match index {
|
||||
Some(i) => i,
|
||||
None => self.textinput.borrow().char_count(),
|
||||
};
|
||||
self.textinput
|
||||
.borrow_mut()
|
||||
.set_edit_point_index(edit_point_index);
|
||||
// trigger redraw
|
||||
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
|
||||
event.PreventDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue