Skip to content

Commit 97f2bae

Browse files
mx-kshitijgjulivan
authored andcommitted
fix: if the document changes the page number input should reset to 1
1 parent 5a79cfb commit 97f2bae

File tree

1 file changed

+8
-0
lines changed
  • packages/pluggableWidgets/document-viewer-web/components

1 file changed

+8
-0
lines changed

packages/pluggableWidgets/document-viewer-web/components/PDFViewer.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ const PDFViewer: DocRendererElement = (props: DocumentRendererProps) => {
9797
}
9898
}, [file, file.status, file.value?.uri]);
9999

100+
// Reset page to 1 when file changes (including content changes)
101+
useEffect(() => {
102+
if (file.value?.uri) {
103+
setCurrentPage(1);
104+
setPageInputValue("1");
105+
}
106+
}, [file.value]);
107+
100108
// Sync page input value with current page
101109
useEffect(() => {
102110
setPageInputValue(currentPage.toString());

0 commit comments

Comments
 (0)