Undocumented panic in iced::widget::scrollable()

I’ve been working on a decently chunky project which needs to take a large number of inputs. For this reason I wanted to make the entire window scollable so on smaller sizes the inputs towards the bottom don’t get squeezed out. However, when I tried to fill wrap the existing view in iced::widget::scrollable I get a runtime panic of

scrollable content must not fill its vertical scrolling axis

I can’t find any documentation for this panic except this issue on github Panic location should be exposed · Issue #2511 · iced-rs/iced · GitHub (which is both for an old version of iced and was closed without an explanation of what was causing the panic) and what’s more I haven’t been able to replicate it either e.g.

use iced::widget as wgt;

#[derive(Debug, Default)]
struct Counter {
    value: i64
}

#[derive(Debug, Clone, Copy)]
enum Message {
    Increment,
    Decrement,
}


impl Counter {
    fn update(&mut self, mesage: Message) {
        match mesage {
            Message::Increment => self.value += 1,
            Message::Decrement => self.value -= 1,
        }
    }

    fn view(&self) -> iced::Element<'_, Message> {

        // * inline of previous section
        wgt::scrollable(
            wgt::column![
                wgt::button("+").on_press(Message::Increment),
                wgt::text(self.value),
                wgt::row![
                    wgt::button("-").on_press(Message::Decrement),
                    wgt::button("-").on_press(Message::Decrement),
                    wgt::button("-").on_press(Message::Decrement),
                ],
                wgt::button("-").on_press(Message::Decrement),
                wgt::button("-").on_press(Message::Decrement),
                wgt::button("-").on_press(Message::Decrement),
                wgt::button("-").on_press(Message::Decrement),
                wgt::button("-").on_press(Message::Decrement),
                wgt::button("-").on_press(Message::Decrement),
                wgt::button("-").on_press(Message::Decrement),
                wgt::button("-").on_press(Message::Decrement),
                wgt::button("-").on_press(Message::Decrement),
                wgt::button("-").on_press(Message::Decrement),
                wgt::button("-").on_press(Message::Decrement),
                wgt::button("-").on_press(Message::Decrement),
                wgt::button("-").on_press(Message::Decrement),
                wgt::button("-").on_press(Message::Decrement),
                wgt::button("-").on_press(Message::Decrement),
                wgt::button("-").on_press(Message::Decrement),
                wgt::button("-").on_press(Message::Decrement),
                wgt::button("-").on_press(Message::Decrement),
                wgt::button("-").on_press(Message::Decrement),
                wgt::button("-").on_press(Message::Decrement),
                wgt::button("-").on_press(Message::Decrement),
                wgt::button("-").on_press(Message::Decrement),
                wgt::button("-").on_press(Message::Decrement),
                wgt::container("hello").style(wgt::container::rounded_box).center_x(iced::Fill)
            ].spacing(10)
        ).into()
    }
}


fn main() -> iced::Result {
    iced::run("A cool counter", Counter::update, Counter::view)
}


#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn counts_correctly() {
        let mut counter = Counter::default();
        counter.update(Message::Increment);
        counter.update(Message::Increment);
        counter.update(Message::Decrement);
        assert_eq!(1, counter.value)
    }
}

(which fills both the vertical and horizontal dimensions) runs without causing this panic. Can anyone explain why this panic occurs as I’d like to both fix my program and add some info to the documentation so whoever runs into this next can work out what’s going on, Thanks,

I figure that you found a bug and not something that needs to be documented so users can work around it. Your best option is to try to reproduce it and report it.

1 Like

Well as I said in the question I haven’t been able to reproduce it (outside of my project) and it’s both an explicit panic (i.e. someone wrote the panic message it isn’t just the program panicking on it’s own) and has previously been discussed on the github page as an issue.

Therefore I’m fairly confident it’s a designed in feature not a bug (though I would argue the behavior should be changed or at least documented)