diff --git a/Libraries/LibWeb/HTML/HTMLSelectElement.cpp b/Libraries/LibWeb/HTML/HTMLSelectElement.cpp index 855b3f4f08c..b27f42b13a8 100644 --- a/Libraries/LibWeb/HTML/HTMLSelectElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLSelectElement.cpp @@ -284,6 +284,8 @@ void HTMLSelectElement::set_selected_index(WebIDL::Long index) for (auto& option : m_cached_list_of_options) option->set_selected_internal(false); + ScopeGuard guard { [&]() { update_inner_text_element(); } }; + if (index < 0 || static_cast(index) >= m_cached_list_of_options.size()) return; diff --git a/Tests/LibWeb/Layout/expected/HTMLSelectElement-selected-index.txt b/Tests/LibWeb/Layout/expected/HTMLSelectElement-selected-index.txt new file mode 100644 index 00000000000..d5acdbb842f --- /dev/null +++ b/Tests/LibWeb/Layout/expected/HTMLSelectElement-selected-index.txt @@ -0,0 +1,27 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x37 [BFC] children: not-inline + BlockContainer at (8,8) content-size 784x21 children: inline + frag 0 from BlockContainer start: 0, length: 0, rect: [13,10 78.390625x17] baseline: 18.5 + BlockContainer at (13,10) content-size 78.390625x17 inline-block [BFC] children: not-inline + Box
at (13,10) content-size 78.390625x17 flex-container(row) [FFC] children: not-inline + BlockContainer
at (13,10) content-size 58.390625x17 flex-item [BFC] children: inline + frag 0 from TextNode start: 0, length: 7, rect: [13,10 58.390625x17] baseline: 13.296875 + "Value 1" + TextNode <#text> + BlockContainer
at (75.390625,10.5) content-size 16x16 flex-item [BFC] children: inline + frag 0 from SVGSVGBox start: 0, length: 0, rect: [75.390625,10.5 16x16] baseline: 16 + SVGSVGBox at (75.390625,10.5) content-size 16x16 [SVG] children: not-inline + SVGGeometryBox at (79.390625,16.21875) content-size 8x4.953125 children: not-inline + TextNode <#text> + TextNode <#text> + +ViewportPaintable (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x37] + PaintableWithLines (BlockContainer) [8,8 784x21] + PaintableWithLines (BlockContainer + + + +