diff --git a/app/note/[id].tsx b/app/note/[id].tsx index 080a1a4..2a8f891 100644 --- a/app/note/[id].tsx +++ b/app/note/[id].tsx @@ -10,6 +10,8 @@ import { Alert, BackHandler, Keyboard, + KeyboardAvoidingView, + Platform, StyleSheet, View, useWindowDimensions, @@ -529,8 +531,19 @@ export default function NoteScreen() { ...state, textBoxes: [...state.textBoxes, box], })); + const needsTrailingBlankPage = pageIndex >= enginePages.length - 1; + const ensureTrailingBlankPage = needsTrailingBlankPage + ? canvasRef.current?.addPage({ force: true, scroll: false }) + : Promise.resolve(); + void ensureTrailingBlankPage?.finally(() => { + // Wait for the keyboard and its layout resize before positioning the + // active line. This preserves the user's current page position. + setTimeout(() => { + canvasRef.current?.revealPagePosition(pageIndex, box.y, true); + }, 250); + }); }, - [mutateOverlay], + [enginePages.length, mutateOverlay], ); const handleUpdateTextBox = useCallback( @@ -752,7 +765,10 @@ export default function NoteScreen() { onExport={() => void handleExport()} /> - + - +