Skip to content

Commit 1a7f097

Browse files
committed
Fix unnecessary clip of text input in iced_wgpu
It should only produce a `Clip` primitive when the contents overflow the input now.
1 parent 9afa318 commit 1a7f097

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

wgpu/src/renderer/widget/text_input.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,16 @@ impl text_input::Renderer for Renderer {
210210
(text_value, Vector::new(0, 0))
211211
};
212212

213-
let contents = Primitive::Clip {
214-
bounds: text_bounds,
215-
offset,
216-
content: Box::new(contents_primitive),
213+
let text_width = self.measure_value(&text, size, font);
214+
215+
let contents = if text_width > text_bounds.width {
216+
Primitive::Clip {
217+
bounds: text_bounds,
218+
offset,
219+
content: Box::new(contents_primitive),
220+
}
221+
} else {
222+
contents_primitive
217223
};
218224

219225
(

0 commit comments

Comments
 (0)