You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-10-27] [$175] Attachments - Chat scroll bar moves by arrow keys when PDF is opened #103576
When you open a chat attachment to view it, nothing inside the modal gets keyboard focus. That means the PDF's scroll container never receives the arrow keys.
The modal's initialFocus returns false unless there is a Send button. The Send button only shows up in the add-attachment flow, so a viewed attachment has no initial focus target.
When the focus trap activates, onActivate blurs the thumbnail you clicked. After that, document.activeElement is <body>.
With <body> focused, Chrome sends ArrowUp/ArrowDown to the scroll container around the last-clicked node. That node is the PDF thumbnail in the chat list, which stays mounted behind the modal. So the chat list scrolls.
react-fast-pdf gives the PDF list's outer div tabIndex=-1 so keyboard scrolling works, but it never focuses that div. The PDF only responds to arrow keys after you click inside it, which matches the "do not click on PDF" step.
PDFView/index.tsx:274-279: the wrapper has tabIndex={0}, but it is the scroller's parent, so focusing it won't scroll the PDF
CarouselActions.tsx:10-34: only ArrowLeft/ArrowRight are handled, so Up/Down fall through to the browser
react-fast-pdf v1.0.34, helpers.tssetListAttributes: sets tabIndex = -1 on react-window's outer div but never calls focus(). It exposes no ref or load-success callback.
What changes do you think we should make in order to solve the problem?
In the web PDFView, focus the PDF's scroll container once it renders. Apply this only when the PDF is the active item in the attachment modal.
Add a ref to the outer View.
Add an effect gated on isUsedInAttachmentModal && !isUsedAsChatAttachment && isFocused !== false && !shouldUsePDFGestureZoom.
The list renders asynchronously after the PDF loads. Use a MutationObserver to wait for the [tabindex="-1"] scroll element inside the container.
When the element appears, call focus({preventScroll: true}) on it, unless focus is already inside the container. This keeps focus on the password form input for protected PDFs. Then disconnect the observer, and also disconnect it on cleanup.
Because this focus happens after the trap's activation blur, the blur won't undo it. Off-screen carousel items are skipped because of the isFocused gate.
What alternative solutions did you explore? (Optional)
Add an autoFocus prop or a listOuterRef prop to react-fast-pdf, then bump the version in App. This is cleaner, but it needs a library release.
Give the modal an initialFocus fallback, such as the carousel container. This stops the chat from scrolling but still won't scroll the PDF, because the focused element would sit above the scroller.
Confidence and open questions
I traced the root cause through the code but haven't reproduced it in a browser.
The App checkout is shallow, so I couldn't confirm which change caused the regression. The issue reproduces in production, so it may have existed for a long time.
Image attachments probably let the chat scroll behind them too. It goes unnoticed because images don't scroll.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/103576) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
changed the title [-]Attachments - Chat scroll bar moves by arrow keys when PDF is opened[/-][+][$175] Attachments - Chat scroll bar moves by arrow keys when PDF is opened[/+]on Oct 9, 2026
Please re-state the problem that we are trying to solve in this issue.
On Chrome, opening a PDF attachment and pressing Up/Down without clicking inside the PDF scrolls the chat behind the attachment viewer instead of the PDF.
What is the root cause of that problem?
The attachment modal does not transfer keyboard focus to the PDF's actual scrollable element. The modal focus trap clears the previous focus, while the PDFView wrapper is not the inner scroll container created by react-fast-pdf. Therefore the browser routes arrow-key scrolling to the background chat.
What changes do you think we should make in order to solve the problem?
In the web PDF attachment viewer, place focus on the PDF previewer's scroll element after it mounts, only when that PDF is the active attachment. Preserve focus if the user is interacting with a password prompt or another control, and restore normal focus behavior on close. Avoid a global arrow-key handler that could interfere with accessibility or other modals.
I'll test Up/Down immediately after opening the PDF, after changing carousel items, with password-protected PDFs, and after closing the modal, including a regression check that the chat no longer scrolls behind it.
Please re-state the problem that we are trying to solve in this issue.
When opening a PDF attachment in the attachment modal on Web or Desktop, pressing the arrow keys (ArrowUp / ArrowDown) without clicking inside the preview first scrolls the background chat list instead of scrolling the PDF document.
What is the root cause of that problem?
A few factors come together to cause this:
In src/pages/media/AttachmentModalScreen/AttachmentModalContainer/index.tsx, initialFocus evaluates to false when viewing existing attachments because contentProps.submitRef is only present during upload and confirmation flows.
In src/components/FocusTrap/FocusTrapForModal/index.web.tsx, when the modal opens, blurActiveElement() blurs whatever was active, leaving document.activeElement on document.body.
When document.body holds focus, browsers route ArrowUp and ArrowDown scrolling to the last active scrollable container in the document hierarchy. In our case, that is the chat's ReportActionsList sitting directly behind the modal overlay.
Upstream react-fast-pdf (src/helpers.ts) already sets ref.tabIndex = -1 on the virtualized <List> outer container via outerRef={setListAttributes} to support programmatic focus without creating an unwanted sequential Tab stop. However, nothing in Expensify/App currently calls .focus() on that element when the attachment modal opens or when carousel slides transition.
In src/components/PDFView/index.tsx, tabIndex={0} is assigned to an outer wrapper <View>, but that wrapper has overflow: hidden and is never focused anyway, causing keyboard arrow events to bypass the PDF preview completely until clicked.
What changes do you think we should make in order to solve the problem?
In src/components/PDFView/index.tsx:
Remove tabIndex={0} from the outer <View> in renderPDFView(). Because that container has overflow: hidden, setting a tab index there is unnecessary and introduces a redundant tab stop.
Attach a ref (containerRef = useRef<View>(null)) to that outer wrapper <View>.
Add a useEffect hook to handle programmatic focusing whenever the PDF is active in the attachment modal (checking !shouldUsePDFGestureZoom && !!isUsedInAttachmentModal && !isUsedAsChatAttachment && isFocused !== false):
Target the scroller directly using .react-pdf__Document > [tabindex="-1"].
This child selector is key: in react-fast-pdf, <List outerRef={setListAttributes}> renders as an immediate child of .react-pdf__Document once pages are ready. For password-protected PDFs, the password input wrapper inside BaseTextInput also happens to have tabIndex={-1}, but it sits outside .react-pdf__Document. Targeting .react-pdf__Document > [tabindex="-1"] ensures our observer will never accidentally match the password input wrapper or disconnect early before the user unlocks the document.
Use a MutationObserver on the container to observe when the PDF scroller mounts into the DOM. Once found, focus the scroller with scrollContainer.focus({preventScroll: true}) and disconnect the observer.
Respect active focus: do not steal focus if the user has already focused or clicked a modal header control (such as the Close or Download buttons).
Set role="region" and aria-label={fileName || translate('attachmentView.unknownFilename')} on the scroll container for accessibility.
Clean up the observer when unmounting or switching slides.
What alternative solutions did you explore? (Optional)
Modifying upstream react-fast-pdf to auto-focus:
Beyond requiring an upstream release and App dependency bump, the upstream library has no awareness of App carousel state (like isFocused). If upstream focused on mount, off-screen pre-rendered carousel slides would steal focus from the current slide.
Capturing arrow keys globally in AttachmentModalContainer:
Manually handling keydown and calling .scrollBy() reinvents native browser scrolling, loses smooth OS scroll acceleration, and risks conflicting with existing modal shortcuts.
Using setTimeout or requestAnimationFrame:
Timer-based approaches are prone to race conditions, particularly on slower devices or larger PDFs where PDF.js page rendering takes variable time. A MutationObserver reacts immediately once the DOM node is ready without arbitrary delays.
Test Plan
Open any chat report that has enough message history for the chat scrollbar to be visible.
Click on a multi-page PDF attachment to open it in the attachment modal.
Without clicking inside the PDF preview, press ArrowDown and ArrowUp on your keyboard:
Verify that the PDF document scrolls up and down smoothly.
Verify that the chat scrollbar in the background stays completely still.
If there are multiple attachments in the report, switch between slides using the carousel arrows:
Navigate to a PDF attachment slide.
Without clicking inside the preview, press ArrowDown and ArrowUp to confirm the active PDF scrolls immediately.
Open a password-protected PDF attachment:
Verify that the password input field receives focus cleanly and arrow keys do not interfere with typing.
Enter the password and unlock the document. Once the pages render, verify that arrow keys scroll the unlocked PDF.
Verify on Mobile Web and Native platforms:
Verify pinch-to-zoom, gesture zoom, and touch scrolling remain smooth and unaffected.
Close the modal:
Verify focus restores cleanly and normal chat navigation works as expected.
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to the comment on the PR: N/A — no offending PR identified.
Link to the comment on the Issue: N/A.
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A — non-critical.
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
Regression Test Proposal
Retain these checks in the existing regression case linked in the issue.
Precondition:
Desktop web; chat with scrollable history and a multi-page PDF.
Test:
Open the PDF without clicking inside it.
Press Down, then Up.
Verify the PDF scrolls and the background chat stays still.
Activity
applause-bot commentedon Oct 9, 2026
While Applause doesn't embed attachments for this bug, here are the links for quick view:
https://platform.applause.com/services/links/v1/external/f9e9feb745b1306a0b6dca45671e82432bcec1d91517082431bde93c66c44083
https://platform.applause.com/services/links/v1/external/ee8e66e456a3647d9b57ced6fb4ed8aabe8105e6dd18c60d41562a2297749b34
MelvinBot commentedon Oct 9, 2026
Proposal
What is the root cause of that problem?
When you open a chat attachment to view it, nothing inside the modal gets keyboard focus. That means the PDF's scroll container never receives the arrow keys.
initialFocusreturnsfalseunless there is a Send button. The Send button only shows up in the add-attachment flow, so a viewed attachment has no initial focus target.onActivateblurs the thumbnail you clicked. After that,document.activeElementis<body>.<body>focused, Chrome sends ArrowUp/ArrowDown to the scroll container around the last-clicked node. That node is the PDF thumbnail in the chat list, which stays mounted behind the modal. So the chat list scrolls.react-fast-pdfgives the PDF list's outer divtabIndex=-1so keyboard scrolling works, but it never focuses that div. The PDF only responds to arrow keys after you click inside it, which matches the "do not click on PDF" step.Code references
initialFocusfalls back tofalsewhensubmitRefis unsetsubmitRefis attached only whenonConfirmis setblurActiveElement()runs on activation, andfallbackFocusisdocument.bodytabIndex={0}, but it is the scroller's parent, so focusing it won't scroll the PDFreact-fast-pdfv1.0.34,helpers.tssetListAttributes: setstabIndex = -1on react-window's outer div but never callsfocus(). It exposes no ref or load-success callback.What changes do you think we should make in order to solve the problem?
In the web
PDFView, focus the PDF's scroll container once it renders. Apply this only when the PDF is the active item in the attachment modal.View.isUsedInAttachmentModal && !isUsedAsChatAttachment && isFocused !== false && !shouldUsePDFGestureZoom.MutationObserverto wait for the[tabindex="-1"]scroll element inside the container.focus({preventScroll: true})on it, unless focus is already inside the container. This keeps focus on the password form input for protected PDFs. Then disconnect the observer, and also disconnect it on cleanup.Because this focus happens after the trap's activation blur, the blur won't undo it. Off-screen carousel items are skipped because of the
isFocusedgate.What alternative solutions did you explore? (Optional)
autoFocusprop or alistOuterRefprop toreact-fast-pdf, then bump the version in App. This is cleaner, but it needs a library release.initialFocusfallback, such as the carousel container. This stops the chat from scrolling but still won't scroll the PDF, because the focused element would sit above the scroller.Confidence and open questions
Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/103576)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
view run
melvin-bot commentedon Oct 9, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @nyomanjyotisa (
External)[-]Attachments - Chat scroll bar moves by arrow keys when PDF is opened[/-][+][$175] Attachments - Chat scroll bar moves by arrow keys when PDF is opened[/+]melvin-bot commentedon Oct 9, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022108506978543409088
yuvrajangadsingh commentedon Oct 9, 2026
withdrawing this, it went up before the issue had the
Help Wantedlabel. will come back if the label is added.camesenin commentedon Oct 9, 2026
melvin-bot commentedon Oct 9, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
krsnak commentedon Oct 9, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
On Chrome, opening a PDF attachment and pressing Up/Down without clicking inside the PDF scrolls the chat behind the attachment viewer instead of the PDF.
What is the root cause of that problem?
The attachment modal does not transfer keyboard focus to the PDF's actual scrollable element. The modal focus trap clears the previous focus, while the
PDFViewwrapper is not the inner scroll container created byreact-fast-pdf. Therefore the browser routes arrow-key scrolling to the background chat.What changes do you think we should make in order to solve the problem?
In the web PDF attachment viewer, place focus on the PDF previewer's scroll element after it mounts, only when that PDF is the active attachment. Preserve focus if the user is interacting with a password prompt or another control, and restore normal focus behavior on close. Avoid a global arrow-key handler that could interfere with accessibility or other modals.
I'll test Up/Down immediately after opening the PDF, after changing carousel items, with password-protected PDFs, and after closing the modal, including a regression check that the chat no longer scrolls behind it.
taieddie commentedon Oct 10, 2026
Contributor details
Your Expensify account email: taieddie8@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~01af851c9a7f771775
Proposal (updated)
Please re-state the problem that we are trying to solve in this issue.
When opening a PDF attachment in the attachment modal on Web or Desktop, pressing the arrow keys (ArrowUp / ArrowDown) without clicking inside the preview first scrolls the background chat list instead of scrolling the PDF document.
What is the root cause of that problem?
A few factors come together to cause this:
src/pages/media/AttachmentModalScreen/AttachmentModalContainer/index.tsx,initialFocusevaluates tofalsewhen viewing existing attachments becausecontentProps.submitRefis only present during upload and confirmation flows.src/components/FocusTrap/FocusTrapForModal/index.web.tsx, when the modal opens,blurActiveElement()blurs whatever was active, leavingdocument.activeElementondocument.body.document.bodyholds focus, browsers route ArrowUp and ArrowDown scrolling to the last active scrollable container in the document hierarchy. In our case, that is the chat'sReportActionsListsitting directly behind the modal overlay.react-fast-pdf(src/helpers.ts) already setsref.tabIndex = -1on the virtualized<List>outer container viaouterRef={setListAttributes}to support programmatic focus without creating an unwanted sequential Tab stop. However, nothing in Expensify/App currently calls.focus()on that element when the attachment modal opens or when carousel slides transition.src/components/PDFView/index.tsx,tabIndex={0}is assigned to an outer wrapper<View>, but that wrapper hasoverflow: hiddenand is never focused anyway, causing keyboard arrow events to bypass the PDF preview completely until clicked.What changes do you think we should make in order to solve the problem?
In
src/components/PDFView/index.tsx:tabIndex={0}from the outer<View>inrenderPDFView(). Because that container hasoverflow: hidden, setting a tab index there is unnecessary and introduces a redundant tab stop.containerRef = useRef<View>(null)) to that outer wrapper<View>.useEffecthook to handle programmatic focusing whenever the PDF is active in the attachment modal (checking!shouldUsePDFGestureZoom && !!isUsedInAttachmentModal && !isUsedAsChatAttachment && isFocused !== false):.react-pdf__Document > [tabindex="-1"].This child selector is key: in
react-fast-pdf,<List outerRef={setListAttributes}>renders as an immediate child of.react-pdf__Documentonce pages are ready. For password-protected PDFs, the password input wrapper insideBaseTextInputalso happens to havetabIndex={-1}, but it sits outside.react-pdf__Document. Targeting.react-pdf__Document > [tabindex="-1"]ensures our observer will never accidentally match the password input wrapper or disconnect early before the user unlocks the document.MutationObserveron the container to observe when the PDF scroller mounts into the DOM. Once found, focus the scroller withscrollContainer.focus({preventScroll: true})and disconnect the observer.role="region"andaria-label={fileName || translate('attachmentView.unknownFilename')}on the scroll container for accessibility.What alternative solutions did you explore? (Optional)
react-fast-pdfto auto-focus:Beyond requiring an upstream release and App dependency bump, the upstream library has no awareness of App carousel state (like
isFocused). If upstream focused on mount, off-screen pre-rendered carousel slides would steal focus from the current slide.AttachmentModalContainer:Manually handling
keydownand calling.scrollBy()reinvents native browser scrolling, loses smooth OS scroll acceleration, and risks conflicting with existing modal shortcuts.setTimeoutorrequestAnimationFrame:Timer-based approaches are prone to race conditions, particularly on slower devices or larger PDFs where PDF.js page rendering takes variable time. A
MutationObserverreacts immediately once the DOM node is ready without arbitrary delays.Test Plan
31 remaining items
nyomanjyotisa commentedon Oct 21, 2026
Contributor+ Checklist:
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to the comment on the PR: N/A — no offending PR identified.
Link to the comment on the Issue: N/A.
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A — non-critical.
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
Regression Test Proposal
Retain these checks in the existing regression case linked in the issue.
Precondition:
Test:
Do we agree 👍 or 👎
melvin-bot commentedon Oct 26, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Oct 26, 2026
Payment Summary
Resolving PRs:
Focus the PDF scroller in the attachment modal so arrow keys scroll the PDF #103836
Reviewer: @nyomanjyotisa owed $175 via NewDot
BugZero Checklist (@mallenexpensify)
melvin-bot commentedon Oct 29, 2026
@mallenexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
mallenexpensify commentedon Oct 30, 2026
Payment Summary
Contributor+: @nyomanjyotisa due $175 via NewDot
Thx for the breakdown about the deploy blocker above