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

fix(obj): readjust scroll after layout when child removed #4916

Merged
merged 1 commit into from
Dec 3, 2023

Conversation

niklasf
Copy link
Contributor

@niklasf niklasf commented Dec 2, 2023

Removing a child element may cause the current scroll position of the parent to become invalid. This was reported and partially fixed in #3210.

Looking at the original reproducer, there's another way to remove obj3 that still exhibits the bug:

    if(code == LV_EVENT_CLICKED) {
        lv_obj_set_parent(obj0, obj2);
        lv_obj_set_parent(obj3, lv_scr_act()); // instead of lv_obj_del_async(obj3);
    }

To fix both, add a general mechanism to call lv_obj_readjust_scroll() after revalidating the layout. This also fixes (or at least significantly improves) the performance issue in #4908.

@niklasf niklasf force-pushed the fix/readjust-scroll-after-layout branch from ec08925 to f9ec084 Compare December 2, 2023 20:21
@kisvegabor
Copy link
Member

I like this solution. It's really generic and fits well to the current mechanism of layout handling.

Thank you!

@kisvegabor kisvegabor merged commit 8a25009 into lvgl:master Dec 3, 2023
15 checks passed
niklasf added a commit to niklasf/lvgl that referenced this pull request Dec 4, 2023
@niklasf niklasf deleted the fix/readjust-scroll-after-layout branch October 4, 2024 15:36
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 this pull request may close these issues.

2 participants