Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested scrolls not working as expected #344

Closed
dominikwilkowski opened this issue Mar 3, 2024 · 0 comments · Fixed by #380
Closed

Nested scrolls not working as expected #344

dominikwilkowski opened this issue Mar 3, 2024 · 0 comments · Fixed by #380

Comments

@dominikwilkowski
Copy link
Contributor

When you try to scroll a nested scroll the scroll will only effect the lowest child even if that child actually has nothing to scroll.

Consider this example:

use floem::{
    keyboard::{Key, ModifiersState, NamedKey},
    view::View,
    views::{label, scroll, v_stack, Decorators},
};

fn app_view() -> impl View {
    let view = scroll(
        v_stack((
            scroll(label(move || "test")),
            scroll(label(move || "test")),
            scroll(label(move || "test")),
            scroll(label(move || "test")),
            scroll(label(move || "test")),
            scroll(label(move || "test")),
            scroll(label(move || "test")),
            scroll(label(move || "test")),
            scroll(label(move || "test")),
            scroll(label(move || "test")),
            scroll(label(move || "test")),
            scroll(label(move || "test")),
            scroll(label(move || "test")),
            scroll(label(move || "test")),
            scroll(label(move || "test")),
        ))
        .style(|s| s.gap(10, 10)),
    )
    .style(|s| s.padding(10).width_full().height_full());

    let id = view.id();
    view.on_key_up(
        Key::Named(NamedKey::F11),
        ModifiersState::empty(),
        move |_| id.inspect(),
    )
}

fn main() {
    floem::launch(app_view);
}

scroll

You can see I can scroll the body of the window only if my mouse is not hovering over the nested scrolls (which don't even have scroll bars or space to scroll). This breaks any dynamic use of scroll where you deal with user input and don't know if the input will be larger. And I don't think there is a way to measure the size of a phantom text node and then decide on that to wrap your text inside a scroll or not.

I wold expect the scrolls that don't actually have anything to scroll (so no overlapping inner body) to not capture the scroll even at all. I would also expect that if you scroll to the end of the inner child scroll you'd then bubble the scroll further up to the parent scrolls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant