From cca03e484be96a3d833beff5834416c3c07dfbb2 Mon Sep 17 00:00:00 2001 From: Colin Reeder Date: Sat, 3 Aug 2024 14:57:00 -0600 Subject: [PATCH] LibWeb: Also invalidate placeholder style on focus change --- Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp | 6 ++++++ Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 94f07734df3..05630127a01 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -1137,6 +1137,9 @@ void HTMLInputElement::did_receive_focus() return; m_text_node->invalidate_style(); + if (m_placeholder_text_node) + m_placeholder_text_node->invalidate_style(); + document().set_cursor_position(DOM::Position::create(realm(), *m_text_node, 0)); } @@ -1145,6 +1148,9 @@ void HTMLInputElement::did_lose_focus() if (m_text_node) m_text_node->invalidate_style(); + if (m_placeholder_text_node) + m_placeholder_text_node->invalidate_style(); + commit_pending_changes(); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp index 56ff3bfcd82..d0d2242ab87 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp @@ -72,6 +72,9 @@ void HTMLTextAreaElement::did_receive_focus() return; m_text_node->invalidate_style(); + if (m_placeholder_text_node) + m_placeholder_text_node->invalidate_style(); + document().set_cursor_position(DOM::Position::create(realm(), *m_text_node, 0)); } @@ -80,6 +83,9 @@ void HTMLTextAreaElement::did_lose_focus() if (m_text_node) m_text_node->invalidate_style(); + if (m_placeholder_text_node) + m_placeholder_text_node->invalidate_style(); + // The change event fires when the value is committed, if that makes sense for the control, // or else when the control loses focus queue_an_element_task(HTML::Task::Source::UserInteraction, [this] {