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

@@ -106,7 +106,7 @@ public:
void update_selectedness();
void update_inner_text_element(Badge<HTMLOptionElement>);
void clone_selected_option_into_select_button();
bool can_skip_selectedness_update_for_inserted_option(HTMLOptionElement const&) const;
@@ -148,7 +148,6 @@ private:
void show_the_picker_if_applicable();
void create_shadow_tree_if_needed();
void update_inner_text_element();
// https://html.spec.whatwg.org/multipage/form-elements.html#send-select-update-notifications
void send_select_update_notifications();