mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:17:36 +00:00
LibWeb: Run the unfocusing steps when a click does not focus anything
For example, when clicking the document body outside of a focused input element, we should unfocus that element.
This commit is contained in:
parent
48240a6fc3
commit
fd297a3248
6 changed files with 42 additions and 0 deletions
23
Tests/LibWeb/Text/input/input-click-to-unfocus.html
Normal file
23
Tests/LibWeb/Text/input/input-click-to-unfocus.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
<input id=input type=text>
|
||||
<script src="include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
let input = document.getElementById("input");
|
||||
|
||||
input.addEventListener("focus", () => {
|
||||
println("focus");
|
||||
});
|
||||
|
||||
input.addEventListener("blur", () => {
|
||||
println("blur");
|
||||
});
|
||||
|
||||
input.focus();
|
||||
|
||||
const rect = input.getBoundingClientRect();
|
||||
const x = rect.x + rect.width;
|
||||
const y = rect.y + rect.height;
|
||||
|
||||
internals.click(x + 10, y + 10);
|
||||
})
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue