mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Do not insert "return" key presses into input element values
When the return key is pressed, we try to handle it as a commit action for input elements. However, we would then go on to actually insert the return key's code point (U+000D) into the input element. This would be sanitized out, but would leave the input element in a state where it thinks it has text to commit. This would result in a change event being fired when the return key is pressed multiple times in a row. We were also firing the beforeinput/input events twice for all return key presses. To fix this, this patch changes the input event target to signify if it actually handled the return key. If not (i.e. for textarea elements), only then do we insert the code point. We also must not fall through to the generic key handler, to avoid the repeated input events.
This commit is contained in:
committed by
Alexander Kalenik
parent
206ec6694c
commit
5f0f97b3cc
Notes:
github-actions[bot]
2025-03-22 16:29:13 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/5f0f97b3cc3 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4036
@@ -11,5 +11,8 @@
|
||||
|
||||
internals.sendText(input, "wfh :^)");
|
||||
internals.commitText();
|
||||
|
||||
// A second commit should not result in a change event.
|
||||
internals.commitText();
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user