From 3ecd9c76068ae47c4295c435fbf63b4d761b4b98 Mon Sep 17 00:00:00 2001 From: John Date: Sat, 6 Dec 2025 21:21:07 +0800 Subject: [PATCH] input: Fix text not in vertical center when masked text is empty. (#1753) Closes #1724 ## Screenshot ### Before CleanShot20251206132455 ### After CleanShot20251206132600 --------- Co-authored-by: Jason Lee Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- crates/story/src/input_story.rs | 1 + crates/ui/src/input/element.rs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/story/src/input_story.rs b/crates/story/src/input_story.rs index 8c4804df..ea0f0e30 100644 --- a/crates/story/src/input_story.rs +++ b/crates/story/src/input_story.rs @@ -65,6 +65,7 @@ impl InputStory { let mask_input = cx.new(|cx| { InputState::new(window, cx) .masked(true) + .placeholder("Enter your password...") .default_value("this-is-password-δΈ­ζ–‡πŸš€πŸŽ‰") }); diff --git a/crates/ui/src/input/element.rs b/crates/ui/src/input/element.rs index 9f57f020..143874ac 100644 --- a/crates/ui/src/input/element.rs +++ b/crates/ui/src/input/element.rs @@ -1179,7 +1179,8 @@ impl Element for TextElement { let invisible_top_padding = prepaint.last_layout.visible_top; let mut mask_offset_y = px(0.); - if self.state.read(cx).masked { + let state = self.state.read(cx); + if state.masked && state.text.len() > 0 { // Move down offset for vertical centering the ***** if cfg!(target_os = "macos") { mask_offset_y = px(3.);