Skip to content

EST: fix document upload on input-fallback browsers (react-dropzone v14)#22

Merged
bhavananarayanan merged 1 commit into
release/est/0.9.7from
fix/dropzone-file-upload-fallback
Jun 26, 2026
Merged

EST: fix document upload on input-fallback browsers (react-dropzone v14)#22
bhavananarayanan merged 1 commit into
release/est/0.9.7from
fix/dropzone-file-upload-fallback

Conversation

@gqcorneby

@gqcorneby gqcorneby commented Jun 25, 2026

Copy link
Copy Markdown

📌 References

📝 Implementation

  • outbound + combined-shipments SendMovementPage — render <input {...getInputProps()} /> inside the <Dropzone> render-prop. react-dropzone v14 no longer auto-renders the input; without it open() clicks a null inputRef and nothing happens.
  • DropzoneFileSelect — destructure onChange out of ...fieldProps so it is no longer spread onto the wrapper <div>. Previously the bubbled native change event invoked the handler with a SyntheticEvent instead of a file array, crashing the inbound send step (Invalid attempt to spread non-iterable instance). onChange is still wired through onDrop.
  • Upstream-only files; edits are surgical (8 insertions). No behaviour change for the FS Access path.

✨ Description of Change

Description:

The "Upload Documents" button did nothing on the outbound send step, and the inbound send step went to a blank screen, on dev/UAT and in Firefox — but not on a developer's localhost.

Root cause is react-dropzone v14: it only uses the browser File System Access API when all of window.isSecureContext && useFsAccessApi (default true) && 'showOpenFilePicker' in window hold — i.e. a secure context AND a Chromium browser. Everywhere else (plain HTTP such as the dev box, or Firefox/Safari on any URL) it falls back to a hidden file <input>, and that fallback path was broken in two ways:

  • The old outbound/combined render-props never rendered the input element, so the fallback inputRef.current.click() hit null.
  • DropzoneFileSelect leaked onChange onto the root <div>, so the native input change event bubbled up and fired the handler with an event object → spread crash.

Both were masked on localhost + Chrome (secure + Chromium → FS Access API, which needs no input element and emits no bubbling change event), which is why it only reproduced off localhost / outside Chrome.

This is an upstream OpenBoxes bug (all three files are upstream); carrying the fix on EST as an interim. A separate upstream PR to PIH is planned so the patch can be dropped on a future version bump.

Upstream touch points (all upstream files — future merge-conflict candidates):

  • src/js/components/form-elements/v2/DropzoneFileSelect.jsx
  • src/js/components/stock-movement-wizard/outbound/SendMovementPage.jsx
  • src/js/components/stock-movement-wizard/combined-shipments/SendMovementPage.jsx

Out of scope: documents persist on Send (dispatch), not on Save — that is existing upstream behaviour and unchanged here.

📹 Screenshots/Screen capture

Tested localhost in firefox

2026-06-25.14-31-34.mp4

🔥 Notes to the tester

Test in Firefox (or any non-Chromium browser, or over plain HTTP) — that is the fallback path the fix repairs. Chrome-on-localhost masks the bug.

  • Outbound send step → "Upload Documents" opens the file dialog and the file appears in the staged list.
  • Inbound (inboundV2) send step → "Upload documents" stages the file with no blank screen / no console error.
  • Combined shipments send step → same as outbound.
  • Complete a Send with a file staged → the document is persisted and visible on the shipment (Download dropdown / show page).
  • Sanity check on Chrome → upload still works (FS Access path unaffected).

react-dropzone v14 only uses the File System Access API in a secure
context AND a Chromium browser (window.isSecureContext && 'showOpenFilePicker'
in window). Everywhere else (plain HTTP, Firefox, Safari) it falls back to a
hidden file <input> — and that fallback path was broken:

- outbound/combined-shipments SendMovementPage rendered the Dropzone
  render-prop without <input {...getInputProps()} />, so open() clicked a
  null input ref and nothing happened.
- DropzoneFileSelect spread {...fieldProps} (still containing onChange) onto
  the wrapper div, so the bubbled native change event invoked the handler
  with a SyntheticEvent instead of a file array, crashing the inbound send
  step (Invalid attempt to spread non-iterable instance).

Masked on localhost-Chrome (FS Access API path) which is why it only
reproduced on dev/UAT and in Firefox.

Upstream touch points (all upstream files):
- src/js/components/form-elements/v2/DropzoneFileSelect.jsx
- src/js/components/stock-movement-wizard/outbound/SendMovementPage.jsx
- src/js/components/stock-movement-wizard/combined-shipments/SendMovementPage.jsx

@anagperal anagperal left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gqcorneby all good!! 🚀

@bhavananarayanan bhavananarayanan merged commit 999e0f1 into release/est/0.9.7 Jun 26, 2026
@bhavananarayanan bhavananarayanan deleted the fix/dropzone-file-upload-fallback branch June 26, 2026 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants