Merge pull request #28626 from overleaf/dp-scroll-to-ai

Add setTimeout to scrolling to ai suggestedfix on gutter click

GitOrigin-RevId: 83663b7b7ee599aad689aee5f5526631a811829c
This commit is contained in:
David
2025-09-23 08:06:11 +00:00
committed by Copybot
parent 78553d40f9
commit 3e72374f36
@@ -8,6 +8,15 @@ import { useRailContext } from '@/features/ide-redesign/contexts/rail-context'
import { useEditorContext } from '@/shared/context/editor-context' import { useEditorContext } from '@/shared/context/editor-context'
import useEventListener from '@/shared/hooks/use-event-listener' import useEventListener from '@/shared/hooks/use-event-listener'
function scrollIntoView(element: Element) {
setTimeout(() => {
element.scrollIntoView({
block: 'start',
inline: 'nearest',
})
})
}
/** /**
* This hook adds an event listener for events dispatched from the editor to the compile logs pane * This hook adds an event listener for events dispatched from the editor to the compile logs pane
*/ */
@@ -25,10 +34,7 @@ export const useLogEvents = (setShowLogs: (show: boolean) => void) => {
) )
if (element) { if (element) {
element.scrollIntoView({ scrollIntoView(element)
block: 'start',
inline: 'nearest',
})
if (suggestFix) { if (suggestFix) {
// if they are paywalled, click that instead // if they are paywalled, click that instead
@@ -37,10 +43,7 @@ export const useLogEvents = (setShowLogs: (show: boolean) => void) => {
) )
if (paywall) { if (paywall) {
paywall.scrollIntoView({ scrollIntoView(paywall)
block: 'start',
inline: 'nearest',
})
paywall.click() paywall.click()
} else { } else {
element element
@@ -66,10 +69,7 @@ export const useLogEvents = (setShowLogs: (show: boolean) => void) => {
) )
if (logEntry) { if (logEntry) {
logEntry.scrollIntoView({ scrollIntoView(logEntry)
block: 'start',
inline: 'nearest',
})
const expandCollapseButton = const expandCollapseButton =
logEntry.querySelector<HTMLButtonElement>( logEntry.querySelector<HTMLButtonElement>(