From 3bd99221cc3b50ba9e038b1875fec91fdea8039b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Wed, 16 Nov 2022 10:01:40 +0100 Subject: [PATCH] Fix padding for `TextInput` with `Length::Units` width --- native/src/widget/text_input.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index ef2f9a176a..14e7e1b71f 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -383,19 +383,17 @@ where { let text_size = size.unwrap_or_else(|| renderer.default_size()); - let text_limits = limits + let padding = padding.fit(Size::ZERO, limits.max()); + + let limits = limits .pad(padding) .width(width) .height(Length::Units(text_size)); - let limits = limits.width(width).height(Length::Shrink); - - let mut text = layout::Node::new(text_limits.resolve(Size::ZERO)); - let padding = padding.fit(text.size(), limits.max()); - let size = limits.pad(padding).resolve(text.size()).pad(padding); + let mut text = layout::Node::new(limits.resolve(Size::ZERO)); text.move_to(Point::new(padding.left.into(), padding.top.into())); - layout::Node::with_children(size, vec![text]) + layout::Node::with_children(text.size().pad(padding), vec![text]) } /// Processes an [`Event`] and updates the [`State`] of a [`TextInput`]