Skip to content

Fix debug-panic in ScrollArea if contents fit without scrolling#7440

Merged
emilk merged 2 commits intoemilk:mainfrom
YgorSouza:fix-scrollbar-offset-empty-range
Aug 14, 2025
Merged

Fix debug-panic in ScrollArea if contents fit without scrolling#7440
emilk merged 2 commits intoemilk:mainfrom
YgorSouza:fix-scrollbar-offset-empty-range

Conversation

@YgorSouza
Copy link
Copy Markdown
Contributor

If the ScrollArea's contents are smaller than the inner rect, but the scrollbar is set to always visible, clicking on it led to a remap from an empty range to calculate the new offset, which triggered a debug assertion in the remap function, because the result is indeterminate.

Since in this case there is no need to scroll, we just skip the remap and set the offset to 0 directly.

If the ScrollArea's contents are smaller than the inner rect, but the
scrollbar is set to always visible, clicking on it led to a remap from
an empty range to calculate the new offset, which triggered a debug
assertion in the remap function, because the result is indeterminate.

Since in this case there is no need to scroll, we just skip the remap
and set the offset to 0 directly.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 9, 2025

Preview available at https://egui-pr-preview.github.io/pr/7440-fix-scrollbar-offset-empty-range
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

@emilk emilk added bug Something is broken egui labels Aug 14, 2025
@emilk emilk changed the title Fix panic in scroll area when contents fit without scrolling Fix debug-panic in ScrollArea if contents fit without scrolling Aug 14, 2025
Copy link
Copy Markdown
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks :)

@emilk emilk added this to the 0.32.1 milestone Aug 14, 2025
@emilk emilk merged commit a7ae101 into emilk:main Aug 14, 2025
27 of 28 checks passed
emilk pushed a commit that referenced this pull request Aug 15, 2025
If the ScrollArea's contents are smaller than the inner rect, but the
scrollbar is set to always visible, clicking on it led to a remap from
an empty range to calculate the new offset, which triggered a debug
assertion in the remap function, because the result is indeterminate.

Since in this case there is no need to scroll, we just skip the remap
and set the offset to 0 directly.

* Closes <#7362>
* [x] I have followed the instructions in the PR template
@hydra
Copy link
Copy Markdown

hydra commented Aug 27, 2025

this for this PR which closes my issue #7362. I'll be sure to try it out when I get some bandwidth.

❤️

Masterchef365 pushed a commit to Masterchef365/egui that referenced this pull request Apr 3, 2026
…k#7440)

If the ScrollArea's contents are smaller than the inner rect, but the
scrollbar is set to always visible, clicking on it led to a remap from
an empty range to calculate the new offset, which triggered a debug
assertion in the remap function, because the result is indeterminate.

Since in this case there is no need to scroll, we just skip the remap
and set the offset to 0 directly.

* Closes <emilk#7362>
* [x] I have followed the instructions in the PR template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something is broken egui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic in ScrollArea in egui 0.32.0

3 participants