1
Fork 0
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:
Timothy Flynn 2023-12-03 09:54:26 -05:00 committed by Andreas Kling
parent 48240a6fc3
commit fd297a3248
6 changed files with 42 additions and 0 deletions

View 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>