mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Auto merge of #25485 - teapotd:textinput-maxlength-del, r=nox
Allow deletions from overflowed textinput Allow deletions from textinput when the length is greater than the max length. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #25420 - [X] There are tests for these changes
This commit is contained in:
commit
5c202ed392
2 changed files with 22 additions and 6 deletions
|
@ -450,12 +450,6 @@ impl<T: ClipboardProvider> TextInput<T> {
|
|||
let allowed_to_insert_count = if let Some(max_length) = self.max_length {
|
||||
let len_after_selection_replaced =
|
||||
self.utf16_len().saturating_sub(self.selection_utf16_len());
|
||||
if len_after_selection_replaced >= max_length {
|
||||
// If, after deleting the selection, the len is still greater than the max
|
||||
// length, then don't delete/insert anything
|
||||
return;
|
||||
}
|
||||
|
||||
max_length.saturating_sub(len_after_selection_replaced)
|
||||
} else {
|
||||
UTF16CodeUnits(usize::MAX)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue