diff --git a/packages/core/src/api-resize-handlers.ts b/packages/core/src/api-resize-handlers.ts index 2df88de..4850fc5 100644 --- a/packages/core/src/api-resize-handlers.ts +++ b/packages/core/src/api-resize-handlers.ts @@ -3,11 +3,11 @@ import type { ResizeContext } from "~/type"; /** * Resize handler that scrolls to restore the iframe's position in the viewport as it was before the resize. * - * *Note:* This behavior only triggers if the iframe is currently being hovered by the user, + * *Note:* This behavior only triggers if the iframe currently has focus, * in order to try to limit the number of scroll as it can affect the user experience. */ -export const updateParentScrollOnResize = ({ previousRenderState, nextRenderState, interactionState }: ResizeContext) => { - if (interactionState.isHovered) { +export const updateParentScrollOnResize = ({ previousRenderState, nextRenderState, iframe }: ResizeContext) => { + if (document.activeElement === iframe) { window.scrollBy(0, nextRenderState.rect.bottom - previousRenderState.rect.bottom); } };