Fix auto_scroll end-following past code blocks / nested scrollables#6642
Merged
Conversation
Two issues broke auto_scroll's end-following when a tall child (e.g. a Markdown code block) was inserted: - The ScrollMetricsNotification listener reacted to *nested* scrollables (a code block renders inside a horizontal scroller), tracking the wrong extent. Only react to this scrollable's own metrics (notification.depth == 0). - _onScroll unpinned purely on proximity (pixels >= max - threshold). A tall insert jumps maxScrollExtent past the threshold in one frame while pixels stays put, flipping to unpinned so it stopped following. Now it only unpins when the user scrolls *up* (pixels decrease) and re-pins at the end; content growing beneath a stationary position keeps it pinned.
Deploying flet-website-v2 with
|
| Latest commit: |
ec0e821
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://61c49988.flet-website-v2.pages.dev |
| Branch Preview URL: | https://auto-scroll-nested-and-jump.flet-website-v2.pages.dev |
The Pyodide↔Dart postMessage transport frames every packet as [type:u8][payload]
(0x00 = MsgPack Flet protocol frame, 0x01 = raw DataChannel frame), and
PyodideConnection.send_message prepends the 0x00 byte. The python_output shim,
however, posted the raw msgpack [7, {...}] with no type byte, so the Dart side
read msgpack's leading 0x92 (array-of-2 marker) as an unknown packet type and
silently dropped every stdout/stderr line — the host page's Console pane never
saw embedded-app output. Prepend the 0x00 type byte in both worker templates
(client + cookiecutter build template).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to the
auto_scrollend-following behavior: it stopped following once a tall child was inserted — most visibly a Markdown code block (streamed text scrolled fine, code blocks did not).Two root causes in
ScrollableControl:Nested scrollables. A Markdown code block renders inside its own horizontally-scrollable widget. The
ScrollMetricsNotificationlistener reacted to those nested notifications too, tracking the wrong (horizontal) extent. Now it ignores nested scrollables (notification.depth != 0), per the standard Flutter guidance.Extent-jump unpin.
_onScrollrecomputed the pinned state purely from proximity (pixels >= maxScrollExtent - threshold). Inserting a tall child jumpsmaxScrollExtentpast that threshold in a single frame whilepixelsstays put, so it flipped to unpinned and stopped following. Streamed text grows in sub-threshold steps so it never tripped. Now it only unpins when the user scrolls up (pixelsdecrease) and re-pins when the position returns to the end; content growing beneath a stationary position keeps it pinned.flutter analyzeon the changed control: no issues.Companion to #6637 (the original follow-content-growth change).
Summary by Sourcery
Ensure scrollable auto-follow behavior remains pinned to the end when content grows, while ignoring nested scrollable metrics.
Bug Fixes: