Skip to content

Truly independent web browser

LibWeb: Let the text input wrapper fill a flex input

Andreas Kling7221cffaa00a
diff --git a/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Libraries/LibWeb/HTML/HTMLInputElement.cpp
index 9ae16aece86..b09617b4da6 100644
--- a/Libraries/LibWeb/HTML/HTMLInputElement.cpp
+++ b/Libraries/LibWeb/HTML/HTMLInputElement.cpp
@@ -1209,6 +1209,8 @@ void HTMLInputElement::create_text_input_shadow_tree()
align-items: center;
white-space: pre;
border: none;
+ flex: 1;
+ min-width: 0;
)~~~"sv);
}
set_own_inline_style(*element, *style);
diff --git a/Tests/LibWeb/Ref/expected/caret-at-end-of-flex-input-ref.html b/Tests/LibWeb/Ref/expected/caret-at-end-of-flex-input-ref.html
new file mode 100644
index 00000000000..a89fcbab3e7
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/caret-at-end-of-flex-input-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<style>
+ input { display: block; font: 20px monospace; width: 400px; border: 1px solid black; outline: none; padding: 4px; }
+</style>
+<input value="is:pr state:open">
+<script>
+ const input = document.querySelector("input");
+ input.focus();
+ input.setSelectionRange(16, 16);
+</script>
diff --git a/Tests/LibWeb/Ref/input/caret-at-end-of-flex-input.html b/Tests/LibWeb/Ref/input/caret-at-end-of-flex-input.html
new file mode 100644
index 00000000000..1b62ee41b4f
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/caret-at-end-of-flex-input.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<link rel="match" href="../expected/caret-at-end-of-flex-input-ref.html">
+<style>
+ input { display: flex; font: 20px monospace; width: 400px; border: 1px solid black; outline: none; padding: 4px; }
+</style>
+<input value="is:pr state:open">
+<script>
+ const input = document.querySelector("input");
+ input.focus();
+ input.setSelectionRange(16, 16);
+</script>