Skip to content

Commit

Permalink
Merge pull request iced-rs#1539 from iced-rs/fix/text-input-padding
Browse files Browse the repository at this point in the history
Fix padding for `TextInput` with `Length::Units` width
  • Loading branch information
hecrj authored Nov 17, 2022
2 parents 5b0dfcd + 3bd9922 commit b4aedce
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions native/src/widget/text_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`]
Expand Down

0 comments on commit b4aedce

Please sign in to comment.