-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
Description
Attach (recommended) or Link to PDF file
https://mozilla.github.io/pdf.js/web/compressed.tracemonkey-pldi-09.pdf
Web browser and its version
Firefox 122.0 (64-bit)
Operating system and its version
Ubuntu 22.04 LTS (64-bit)
PDF.js version
Latest (from https://mozilla.github.io/pdf.js/web/viewer.html)
Is the bug present in the latest PDF.js version?
Yes
Is a browser extension
No
Steps to reproduce the problem
- Open any PDF document in the PDF.js viewer (e.g., https://mozilla.github.io/pdf.js/web/viewer.html?file=compressed.tracemonkey-pldi-09.pdf)
- Note the total number of pages (e.g., 14 pages)
- Click on the page number input field in the toolbar
- Enter an invalid page number:
- Enter
0(less than minimum) - OR enter a number greater than total pages (e.g.,
999)
- Enter
- Press
Enterkey
What is the expected behavior?
he user should receive clear feedback when entering an invalid page number:
Option 1 (Preferred):
- Input field shows a brief visual error indication (red border/background)
- A tooltip or small message appears: "Please enter a page between 1 and 14"
- Input automatically resets to the current page number after 2 seconds
Option 2:
- Input is automatically clamped to valid range
- For
0→ jumps to page 1 - For
999→ jumps to last page (14)
Option 3:
- Dialog/alert notifies user: "Invalid page number. Please enter a number between 1 and 14"
What went wrong?
Actual behavior:
- No visual feedback occurs
- No error message appears
- The viewer silently stays on the current page
- The input field shows the invalid number briefly, then reverts
- User receives no indication that their input was invalid
Why this is problematic:
- Poor UX - Users are confused why nothing happens
- Accessibility issue - Screen reader users get no feedback
- Common mistake - Easy to mistype or forget page count
- Violates best practices - Form inputs should validate and provide feedback
Link to a viewer
https://mozilla.github.io/pdf.js/web/viewer.html?file=compressed.tracemonkey-pldi-09.pdf
Additional context
Comparison with other PDF viewers
Adobe Acrobat Reader:
- Shows error message: "Please enter a value between 1 and [total]"
- Input field highlights in red
Chrome PDF Viewer:
- Automatically clamps to valid range
- Goes to page 1 if too low, last page if too high
Firefox built-in PDF Viewer:
- Shows inline validation message
- Prevents navigation with invalid input
Foxit Reader:
- Dialog box with error message
- Input field retains focus for correction
Technical Implementation Notes
The issue appears to be in the page number validation logic. Looking at the codebase:
File: web/app.js (around line 3241)
function onPageNumberChanged(evt) {
const { pdfViewer } = this;
if (evt.value !== "") {
this.pdfLinkService.goToPage(evt.value);
}
// ... rest of function
}Reactions are currently unavailable