mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-18 00:02:01 +00:00
LibWeb: Hide inner text of input element when showing placeholder
This commit is contained in:
parent
b4bae912c9
commit
4205ac778f
Notes:
sideshowbarker
2024-07-17 02:21:14 +09:00
Author: https://github.com/bplaat
Commit: 4205ac778f
Pull-request: https://github.com/SerenityOS/serenity/pull/23551
Reviewed-by: https://github.com/trflynn89
4 changed files with 68 additions and 4 deletions
|
@ -601,11 +601,12 @@ void HTMLInputElement::update_placeholder_visibility()
|
|||
{
|
||||
if (!m_placeholder_element)
|
||||
return;
|
||||
auto placeholder_text = this->placeholder_value();
|
||||
if (placeholder_text.has_value()) {
|
||||
if (this->placeholder_value().has_value()) {
|
||||
MUST(m_placeholder_element->style_for_bindings()->set_property(CSS::PropertyID::Display, "block"sv));
|
||||
MUST(m_inner_text_element->style_for_bindings()->set_property(CSS::PropertyID::Display, "none"sv));
|
||||
} else {
|
||||
MUST(m_placeholder_element->style_for_bindings()->set_property(CSS::PropertyID::Display, "none"sv));
|
||||
MUST(m_inner_text_element->style_for_bindings()->set_property(CSS::PropertyID::Display, "block"sv));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -767,7 +768,7 @@ void HTMLInputElement::create_text_input_shadow_tree()
|
|||
m_placeholder_element = MUST(DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML));
|
||||
m_placeholder_element->set_use_pseudo_element(CSS::Selector::PseudoElement::Type::Placeholder);
|
||||
MUST(m_placeholder_element->set_attribute(HTML::AttributeNames::style, R"~~~(
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
height: 1lh;
|
||||
)~~~"_string));
|
||||
MUST(element->append_child(*m_placeholder_element));
|
||||
|
@ -779,7 +780,7 @@ void HTMLInputElement::create_text_input_shadow_tree()
|
|||
|
||||
m_inner_text_element = MUST(DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML));
|
||||
MUST(m_inner_text_element->set_attribute(HTML::AttributeNames::style, R"~~~(
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
height: 1lh;
|
||||
)~~~"_string));
|
||||
MUST(element->append_child(*m_inner_text_element));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue