fix: scroll bottom when generation text #4323
Merged
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.
Describe Your Changes
The changes in this Git diff can be summarized as follows:
Use of
requestAnimationFrame
:requestAnimationFrame
calls from two places where scrolling is performed. This was used to schedule the scroll operation to occur optimally in the browser's next repaint cycle.Direct Scrolling:
scrollTo
onparentRef.current
without wrapping it in arequestAnimationFrame
. This may have been done to simplify the logic or because the timing provided byrequestAnimationFrame
wasn't necessary.Dependency Array Modifications in
useEffect
:currentThread?.id
to the dependency array of bothuseEffect
hooks. This ensures that the effects are re-executed whenevercurrentThread?.id
changes, which might be to ensure that the scrolling logic considers a change in the thread being viewed.Code Simplification:
requestAnimationFrame
wrapping, under the assumption that immediate execution provides the desired behavior without visual issues like jank.Overall, these changes simplify the scrolling logic in the
ChatBody
component by removing unnecessary scheduling of the scroll operation and making the effects more responsive to changes in thecurrentThread
.Fixes Issues
Self Checklist