Chat panel follows its tail by scrolling its own body (SidePanel body gets data-slot side-panel-body) instead of scrollIntoView, which scrolls every ancestor
This commit is contained in:
@@ -179,7 +179,10 @@ export function ChatPanel() {
|
|||||||
const tailLength = tail && "text" in tail ? tail.text.length : 0
|
const tailLength = tail && "text" in tail ? tail.text.length : 0
|
||||||
// biome-ignore lint/correctness/useExhaustiveDependencies: scroll when the list or a streamed answer grows, not on every render.
|
// biome-ignore lint/correctness/useExhaustiveDependencies: scroll when the list or a streamed answer grows, not on every render.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
bottom.current?.scrollIntoView({ block: "end" })
|
// Only the panel's body moves: `scrollIntoView` would scroll every
|
||||||
|
// ancestor too, which is how the logs panel slid the code editor away.
|
||||||
|
const body = bottom.current?.closest("[data-slot=side-panel-body]")
|
||||||
|
body?.scrollTo({ top: body.scrollHeight })
|
||||||
}, [shown.length, tailLength, waiting])
|
}, [shown.length, tailLength, waiting])
|
||||||
|
|
||||||
const send = async () => {
|
const send = async () => {
|
||||||
|
|||||||
@@ -252,6 +252,7 @@ export function SidePanel({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
data-slot="side-panel-body"
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex min-h-0 flex-1 flex-col",
|
"flex min-h-0 flex-1 flex-col",
|
||||||
expanded ? "overflow-hidden" : "overflow-y-auto",
|
expanded ? "overflow-hidden" : "overflow-y-auto",
|
||||||
|
|||||||
Reference in New Issue
Block a user