Skip to content

Container expands each frame if text input has space after it #2285

Open
@IS2511

Description

@IS2511

Describe the bug

Assuming horizontal layout, adding space (ex: ui.add_space(10.0)) after a TextEdit::singleline makes the container (ex: window) expand to the right each frame until it reaches desired_width of the TextEdit.

To Reproduce

Steps to reproduce the behavior:

  1. New project with eframe on linux, default backend.
  2. Paste the example code (below) in the egui update function.
  3. Run the app.
  4. (Optional) Change desired_width to f32:INFINITY to make the container expand infinitely.

Shrinking the window by hand after it grew can make it temporary smaller, but it will grow back again once released.

egui::Window::new("Sample text").show(ctx, |ui| {
    ui.horizontal(|ui| {
        let mut text = String::new();
        egui::TextEdit::singleline(&mut text)
            .desired_width(400.0)
            // .desired_width(f32::INFINITY)
            .show(ui);
        ui.add_space(10.0);
    });
});

Expected behavior

Adding space after a text input makes the window size accommodate that extra space and not grow each frame until it fits.

Having an infinite desired_width should not grow the container. From documentation:

pub fn desired_width(self, desired_width: f32) -> Self

Set to 0.0 to keep as small as possible. Set to f32::INFINITY to take up all available space (i.e. disable automatic word wrap).

Screen captures

With desired_width(400.0):

vokoscreenNG-2022-11-11_15-57-57_short.mp4

With .desired_width(f32::INFINITY):

vokoscreenNG-2022-11-11_16-01-58_short.mp4

Desktop

  • OS: ParrotOS Linux 5.18.0-14parrot1-amd64 Debian 5.18.14-1parrot1 (2022-08-07) x86_64 GNU/Linux
  • Version: eframe 8ff1396

Extra

Manually added space after the text input should not be considered available space. Or is that intended behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is brokentextProblems related to text

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions