mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-01 03:57:15 +02:00
When editing or changing the selection inside an <input> or <textarea>, we should scroll the container so the cursor is always visible. Note that currently the cursor might still become invisible at the end of the container since we do not reserve enough space for it to be made visible.
34 lines
927 B
HTML
34 lines
927 B
HTML
<!DOCTYPE html>
|
|
<style>
|
|
input {
|
|
font-size: 16px;
|
|
width: 100px;
|
|
padding: 2px;
|
|
border: 1px solid;
|
|
}
|
|
</style>
|
|
<input value="foobarbazloremipsum foobarbazloremipsum" />
|
|
<script src="include.js"></script>
|
|
<script>
|
|
test(() => {
|
|
const input = document.querySelector("input");
|
|
input.offsetWidth;
|
|
input.focus();
|
|
|
|
// Click near the left edge before scrolling.
|
|
const rect = input.getBoundingClientRect();
|
|
const x = rect.left + 5;
|
|
const y = rect.top + rect.height / 2;
|
|
internals.click(x, y);
|
|
println(`before: ${input.selectionStart}`);
|
|
|
|
// Move cursor to the end, which should scroll the input.
|
|
input.setSelectionRange(39, 39);
|
|
input.offsetWidth;
|
|
|
|
// Click in the same spot after scrolling.
|
|
internals.click(x, y);
|
|
println(`after: ${input.selectionStart}`);
|
|
});
|
|
</script>
|