diff --git a/Userland/Libraries/LibWeb/HTML/Navigable.cpp b/Userland/Libraries/LibWeb/HTML/Navigable.cpp
index b5adf8baa2c..4f0f0e75e01 100644
--- a/Userland/Libraries/LibWeb/HTML/Navigable.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Navigable.cpp
@@ -2147,13 +2147,20 @@ void Navigable::select_all()
auto document = active_document();
if (!document)
return;
- auto* body = document->body();
- if (!body)
- return;
+
auto selection = document->get_selection();
if (!selection)
return;
- (void)selection->select_all_children(*document->body());
+
+ if (auto position = document->cursor_position(); position && position->node()->is_editable()) {
+ auto& node = *position->node();
+ auto node_length = node.length();
+
+ (void)selection->set_base_and_extent(node, 0, node, node_length);
+ document->set_cursor_position(DOM::Position::create(document->realm(), node, node_length));
+ } else if (auto* body = document->body()) {
+ (void)selection->select_all_children(*body);
+ }
}
void Navigable::paste(String const& text)