fix: Console does not scroll to bottom when code run from notebook #2114
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.
Noticed running code from a notebook wasn't scrolling to the bottom.
I didn't catch this behavior changing in #2076, but looks like the
componentDidUpdate
doesn't necessarily wait until after the paint or the ref isn't updated for some reason. So thescrollHeight
can be the old value and thenscrollTo
(orscrollTop = scrollHeight
) triggers thescroll
event which setsisStuckToBottom
to false. Not exactly sureThe
requestAnimationFrame
call seems to be working. The other option I thought of what ignoring programmatic scrolling, but the only way I saw to do that was to set some state in the class and then check it in the scroll handler and reset it after. There's nothing about the event that indicates if it was triggered viascrollTo
.There were some weird update values when I was logging this. Like the height would be 1900 for 3 renders, then 1700, then 1900 again. Guessing it's due to rendering of the console buttons.