Skip to content

Commit d58c632

Browse files
committed
fix(review-editor/mobile): reset scroll after iOS keyboard dismisses
After saving or cancelling an annotation, iOS Safari was leaving a phantom scroll offset under the app — the keyboard had pushed the focused textarea into view and the offset wasn't reverting on close. Two changes: - Outer shell uses position: fixed inset-0 instead of h-[100dvh] so the document itself can't scroll regardless of what iOS does with the visual viewport. - New closeAnnotationSheet helper blurs the active element (releases the keyboard) and resets window.scrollTo(0,0) on the next frame. Wired to both Cancel and Save paths.
1 parent d522789 commit d58c632

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

packages/review-editor/components/MobileReviewView.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,22 +520,34 @@ export const MobileReviewView: React.FC<MobileReviewViewProps> = ({
520520
});
521521
}, []);
522522

523+
// Closing the annotation sheet also has to clean up after the iOS
524+
// keyboard: blur whatever's focused and reset any scroll offset the
525+
// keyboard introduced. Without this the page can keep an empty
526+
// strip below the app once the keyboard dismisses.
527+
const closeAnnotationSheet = useCallback(() => {
528+
setIsSheetOpen(false);
529+
if (document.activeElement instanceof HTMLElement) {
530+
document.activeElement.blur();
531+
}
532+
requestAnimationFrame(() => window.scrollTo(0, 0));
533+
}, []);
534+
523535
const handleSaveAnnotation = useCallback(
524536
(type: CodeAnnotationType, text: string) => {
525537
if (!selection) return;
526538
const filePath = files[selection.fileIdx]?.path;
527539
if (!filePath) return;
528540
onAddAnnotation(filePath, selection.side, selection.start, selection.end, type, text);
529541
setSelection(null);
530-
setIsSheetOpen(false);
542+
closeAnnotationSheet();
531543
},
532-
[selection, files, onAddAnnotation],
544+
[selection, files, onAddAnnotation, closeAnnotationSheet],
533545
);
534546

535547
const selectionFilePath = selection ? files[selection.fileIdx]?.path : undefined;
536548

537549
return (
538-
<div className="h-[100dvh] flex flex-col bg-background overflow-hidden">
550+
<div className="fixed inset-0 flex flex-col bg-background overflow-hidden">
539551
{/* ---------- Header ---------- */}
540552
<header className="px-3 py-2 border-b border-border/50 bg-card/80 backdrop-blur-xl flex items-center gap-1 z-10">
541553
<div className="min-w-0 flex-1">
@@ -703,7 +715,7 @@ export const MobileReviewView: React.FC<MobileReviewViewProps> = ({
703715
<AnnotationSheet
704716
selection={selection}
705717
filePath={selectionFilePath}
706-
onCancel={() => setIsSheetOpen(false)}
718+
onCancel={closeAnnotationSheet}
707719
onSave={handleSaveAnnotation}
708720
/>
709721
)}

0 commit comments

Comments
 (0)