mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-08 09:35:15 +00:00
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).
23 lines
637 B
HTML
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>
|