LibWeb: Allow selecting text in dialog and label elements

We were previously not allowing the user to select text when the clicked
position represented a click-focusable area. This included text within
dialogs (as the dialog element is click-focusable) and labels (as the
associated input element would be considered click-focusable).

We now no longer consider associated input elements when clicking on a
label. This is handled separately already by the label's activation
behavior steps, so there is no loss of functionality here. In those
steps, though, we now no longer propagate the click event to the input
element if a selection was made during the click. This matches the
behavior of Firefox and Chrome.

With label elements no longer considered here, we can then enter the
character selection mode when click-focusable areas are clicked.
This commit is contained in:
Timothy Flynn
2026-02-17 10:09:24 -05:00
committed by Jelle Raaijmakers
parent a055e36715
commit 7c9b3c08fa
Notes: github-actions[bot] 2026-02-17 17:38:35 +00:00
7 changed files with 71 additions and 36 deletions

View File

@@ -0,0 +1,20 @@
<!DOCTYPE html>
<script src="include.js"></script>
<label for="input" id="label">This is a label</label>
<input id="input" value="This is an input" />
<script>
test(() => {
let { x, y, width, height } = label.getBoundingClientRect();
x += width / 4;
y += height / 2;
internals.mouseDown(x, y);
x += width / 2;
internals.mouseMove(x, y);
internals.mouseUp(x, y);
println(`"${window.getSelection()}"`);
printElement(document.activeElement);
});
</script>