Skip to content

Update Scroller When Exists - Fix Layout Exception - #382

Merged
migueldeicaza merged 1 commit into
migueldeicaza:mainfrom
thecoolwinter:fix/scroller-break-swiftui
Jul 15, 2025
Merged

Update Scroller When Exists - Fix Layout Exception#382
migueldeicaza merged 1 commit into
migueldeicaza:mainfrom
thecoolwinter:fix/scroller-break-swiftui

Conversation

@thecoolwinter

Copy link
Copy Markdown
Contributor

Fixes a layout exception due to the removal of the scroller during constraint layout. This happened when the view was embedded in a SwiftUI view and SwiftUI attempted to update its frame, which caused the scroller to be removed from the view hierarchy which is illegal.

To fix I just removed the removal of the old scroller and updated its frame if it's not nil. This avoids a view tree update and still updates the scroller's position and size.

@migueldeicaza
migueldeicaza merged commit eff9197 into migueldeicaza:main Jul 15, 2025
1 check failed
@migueldeicaza

Copy link
Copy Markdown
Owner

Thank you for your fix!

Comment on lines -306 to -307
if scroller != nil {
scroller.removeFromSuperview()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That is a workaround for the scroller not responding to frame updates. Without re-adding the scroller, it does not layout properly. I introduced the workarond here #362
Now when it is reverted, the previous problem reappeared.

min-median-max pushed a commit to min-median-max/SwiftTerm that referenced this pull request Jan 18, 2026
…break-swiftui

Update Scroller When Exists - Fix Layout Exception
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.

3 participants