Files
ladybird/Tests/LibWeb/Text/input/UIEvents/KeyEvent-tab.html
Timothy Flynn 96b5646fc1 LibWeb: Properly handle when (shift+)tab wraps around the page
We have support for using (shift+)tab to move focus to the next/previous
element on the page. However, there were several ways for this to crash
as written. This updates our implementation to check if we did not find
a node to move focus to, and to reset focus to the first/last node in
the document.

This doesn't seem to work when wrapping around from the first to the
last node. A FIXME has been added for that, as this would already not
work before this patch (the main focus here is not crashing).
2024-10-10 10:41:10 +02:00

23 lines
637 B
HTML

<input id="input1" />
<input id="input2" />
<script src="../include.js"></script>
<script>
test(() => {
let input1 = document.getElementById("input1");
let input2 = document.getElementById("input2");
input1.addEventListener("keydown", e => {
println(`input1 keydown ${e.key}`);
});
input2.addEventListener("keydown", e => {
println(`input2 keydown ${e.key}`);
});
internals.sendKey(input1, "Tab");
printElement(document.activeElement);
internals.sendKey(input2, "Tab");
printElement(document.activeElement);
});
</script>