LibWeb: Keep select button text in sync with the selected option

Previously, the select button's text was only refreshed inside the
two non-trivial branches of the selectedness setting algorithm.
Paths that left the select with exactly one selected option hit a
no-op branch and skipped the refresh.

Fix this by implementing the "clone selected option into select
button" algorithm and invoking it whenever the set of selected options
may have changed.
This commit is contained in:
Tim Ledbetter
2026-04-21 21:53:59 +01:00
committed by Tim Flynn
parent 884a0140aa
commit da5e002db1
Notes: github-actions[bot] 2026-04-22 13:16:46 +00:00
5 changed files with 68 additions and 25 deletions

View File

@@ -54,7 +54,7 @@ void HTMLOptionElement::update_selection_label()
{
if (selected()) {
if (auto* select_element = first_ancestor_of_type<HTMLSelectElement>()) {
select_element->update_inner_text_element({});
select_element->clone_selected_option_into_select_button();
}
}
}