Skip to content

NumberInput surprising/wrong behaviour with width & content_width #286

@StillGreen-san

Description

@StillGreen-san

the number_input widget has two functions for setting the width (width & content_width). and as far as i call tell its also the only widget that has content_width

setting none or both (of width & content_width) to Fill works as expected, but using only one of them can result in (imo) surprising/wrong behaviour

as an example having two elements in a row, a number_input and a button(that is set to Fill):

let txt_minute = number_input(self.value, 0..999999, Message::NumInpChanged)
    .style(number_input::number_input::primary)
    // .width(Length::Fill)
    // .content_width(Length::Fill)
    .padding(0);
let btn_btn = Button::new(Text::new("Button"))
    .width(Length::Fill)
    .height(Length::Fill);
let content = Row::new()
    .push(txt_minute)
    .push(btn_btn)
    .align_y(Vertical::Center);

left: default width; right: setting only width to Fill; they work as exepcted

2024-09-03-20-08_number_input_row_none 2024-09-03-20-09_number_input_row_width

but if they each are in a column (together in a row)

let content = Row::new()
    .push(Column::new().push(txt_minute))
    .push(Column::new().push(btn_btn))
    .align_y(Vertical::Center);

then the number_input will only render as if not set to Fill, but with the column as Fill

2024-09-03-20-11_number_input_rowcol_width

and setting only content_width to Fill will take up all space (in both row and rowcol layouts)

2024-09-03-20-09_number_input_row_content


im also wondering why there are both width and content_width functions, other settings like padding only have one and set the property on both the number_input and the text_input content.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions