While working at PuppyAgent, I was adding file uploads to our React Flow workflow editor. The interaction sounded straightforward: click an area inside a file node, open the browser's file picker, and pass the selected file to the upload logic. The node already had a title editor, toolbar, resize control, and connection handles. The file input was one more interaction inside that crowded component.
On March 5, 2025, I reached a particularly frustrating state: the upload area's click handler ran, and inputRef.current contained an input element, but the file picker did not appear. My original question was:
why the input file ref.click is not trriggered
— My question in the conversation I supplied for this retrospective.1
The repair I describe here is to let the file input's click keep its default behavior. Remove or narrow any handler that calls preventDefault() on that event. Where the upload control needs to stay separate from node selection or dragging, use event propagation controls and React Flow's interaction classes. Keep preventDefault() where it serves a different purpose, such as allowing a file drop.
I use a small reproduction below to show the failure and verify the repair. It also explains why an existing ref and a running click handler do not guarantee that the browser will open a picker.
Note on dates: The Cursor record dates this debugging session to March 5, 2025. The article uses that historical date; midnight is a date-only placeholder. The upload component was committed on March 6. I prepared this retrospective and its repair example on November 17, 2026, reflected in last_modified_at. Conversation times below use UTC+8 and refer to the following assistant request's timestamp; the user messages do not have independently stored timestamps.
What I was trying in Cursor
I started the session Fixing File Input Overlap Issue on March 5 at 15:01:54. The initial problem was layout: the file input overlapped the node's top bar. I then asked to turn it into a drop zone. Soon I was reporting that dropped files were not being logged, followed by the click problem.2
My prompts became increasingly specific:
the onclick is triggered but input element didn't triiger
— My prompt around 15:22, original spelling retained.2
Then, after checking a visible input:
no visible input also can't be trriggereed
— My prompt around 15:27.2
By around 16:00, I had pasted this handler into Cursor. This is the original snippet, with indentation normalized:2
onClick={(e) => {
console.log(inputRef.current) // ouptut is not null here
inputRef.current?.click();//but this doesn't work
inputRef.current?.click();
inputRef.current?.click();
inputRef.current?.click();
}}
Calling it four times was a fairly clear sign that I had run out of useful observations. Another call did not tell me whether the first one dispatched an event, whether anything canceled it, or whether the browser accepted the picker request.
The local session contains this exact four-call prompt. I have retained the technical questions alongside the longer transcript I supplied for this article.12
| Date and time, UTC+8 | What I was working on |
|---|---|
| March 5, around 15:02 | I asked about the file input overlapping the top bar. |
| March 5, around 15:16–15:17 | I requested a drop zone, then reported that dropped files were not logged. |
| March 5, around 15:22–15:27 | I reported that clicking ran the handler without opening the input, including when the input was visible. |
| March 5, around 16:00 | I supplied the non-null ref and repeated .click() calls. |
| March 6, 16:57:34 | I committed 96d2d625, “new ui for file upload node,” introducing PuppyUpload and integrating it into FileNode. |
The next day's commit moved the upload UI into its own component.3
What the committed implementation actually did
The March 6 commit extracted the upload UI into PuppyUpload.tsx. It included drag-and-drop handling, a list of uploaded items, an add-more button, and an uploading overlay. The click handler still called inputRef.current?.click() once. The file input used ReactDOM.createPortal(..., document.body).3
This shortened reconstruction retains the relevant structure and positioning values. I have omitted unrelated attributes and UI; it is not a verbatim source excerpt:4
<>
<div onClick={()=> inputRef.current?.click()}>
Browse files
</div>
{ReactDOM.createPortal(
<input
type="file"
ref={inputRef}
onChange={handleInputChange}
onClick={(e)=> e.stopPropagation()}
style={{ position: 'fixed', top: '-100%', left: '-100%' }}
/>,
document.body
)}
</>
One detail matters: the committed input was still positioned off-screen. The change cannot be described as removing negative coordinates to make .click() work. It changed the input's DOM location and separated the upload UI from the rest of the node, alongside other changes.
A portal changes physical DOM ancestry. It can therefore change which native ancestors surround the input and which container styles affect it. React's event ancestry is different. Its documentation explicitly says:
Events from portals propagate according to the React tree rather than the DOM tree.
— React documentation,
createPortal, “Caveats.”5
Moving an input to document.body does not automatically isolate it from every React handler. The input's stopPropagation() also does not undo a cancellation that already occurred during capture. The fix for a canceled click belongs in the handler that cancels it; a portal is not a substitute for that change.
The earlier answers mixed together different failure points
The supplied answer suggested:
If another element is overlapping the file input (even if it's hidden), the browser might not trigger the file dialog.
— Assistant response in my supplied transcript, section 1.1
That explanation needs a distinction. An overlay can intercept the user's physical pointer interaction. But once my upload handler has run and calls input.click(), that call dispatches a click on the referenced element; it does not perform pointer hit testing at the input's screen coordinates. MDN describes click() as simulating a click, with disabled controls excluded.6
Similarly, hiding the input is not inherently a problem. MDN documents the custom-button pattern using display: none and .click().7 Changing my off-screen styles to display: none would simplify the markup, but that alone would not diagnose why the existing handler failed. My report that the visible input also failed was a reason to investigate the surrounding interaction, not keep changing visibility.
I now separate the sequence this way:
User activates the upload control
→ its handler calls input.click()
→ the input's click event is dispatched
→ the browser may open the file picker
→ a changed selection produces change
→ application code starts uploading
There are two click events here: the original control's click and the input's click. stopPropagation() stops further propagation of an event; it does not cancel its default behavior.8 preventDefault() cancels a cancelable event's default behavior.9 Calling it on the original upload control does not automatically cancel the separate input click. Calling it on the input's click, including from an ancestor listener, can prevent the picker action.
In the original component, the input was outside the clickable drop-zone element and already stopped propagation. Removing preventDefault() only from the drop zone would therefore miss an ancestor capture handler that canceled the input's own click. The repair needs to target the cancellation on that event's path.
The browser also gates picker display on user activation. The HTML Standard's picker algorithm checks for transient activation and consumes it.10 I would keep the call directly inside the user interaction, without an unnecessary network wait or timer. Repeating .click() cannot create a fresh user gesture.
Finally, no change log does not prove that no click occurred. The picker may have opened and been canceled, or the user may have selected the same files again. MDN documents cancellation and unchanged selection separately from a new selection.11 In this case, my explicit report that the picker did not open was more useful than the missing handleFileChange log alone.
Fix the handler that cancels the input click
Here is the failure in a small React example. The outer capture handler cancels every click, including the click dispatched by inputRef.current?.click(). The input's listener can still run, but the browser's picker action is canceled:
<div onClickCapture={(event)=> event.preventDefault()}>
<button type="button" onClick={()=> inputRef.current?.click()}>
Choose files
</button>
<input ref={inputRef} type="file" style={{ display: 'none' }} />
</div>
Remove the blanket cancellation if it is unnecessary. If the surrounding component still needs it for other interactions, exclude the file input's click before calling preventDefault():
onClickCapture={(event) => {
const target = event.target;
if (target instanceof HTMLInputElement && target.type === 'file') {
return; // Preserve the browser's file-picker action.
}
event.preventDefault(); // Retain only if other interactions require it.
}}
Apply this at the listener responsible for cancellation. Adding stopPropagation() to the input cannot undo an earlier capture-phase preventDefault(). For a bubble-phase ancestor handler, stopping propagation at the input can keep the event from reaching that ancestor. If the input's own handler calls preventDefault(), remove that call and use only stopPropagation() when propagation is what needs to be stopped.89
These are newly written repair examples. The historical commit above records the portal implementation; the examples isolate event cancellation and demonstrate the fix without presenting them as an exact historical patch.
Verifying the failure and the repair
For this retrospective, I wrote a separate DOM fixture and checked it with Playwright and headless Chromium 138.0.7204.23. Each case used a browser-driven click on a visible button, whose handler called the input's .click() once. I observed Playwright's filechooser event.12
| Isolated condition | Picker request observed |
|---|---|
Input has display: none | Yes |
Input has fixed positioning with top and left set to -100% | Yes |
Input has pointer-events: none | Yes |
| Another element covers the input | Yes |
| The initiating button cancels its own click | Yes |
| An ancestor capture listener cancels the input's click | No; the input click listener still runs |
| The input stops propagation after an ancestor has canceled its click | No |
| The ancestor capture listener exempts the file input's click | Yes |
| The input stops propagation without canceling its click | Yes |
The repair changes the result from no picker request to one picker request: the ancestor no longer cancels the input click. Stopping propagation after cancellation leaves the failure in place. The visibility cases also show why moving the input or changing its CSS is unnecessary for this reproduction.
The checks use synthetic HTML and observe picker requests in headless Chromium; they do not exercise an operating-system dialog or the application's upload backend. I have kept the check script and results with this article.
The final upload-control pattern
After removing the unwanted cancellation, I keep the upload control separate from the node's drag and pan interactions. React Flow provides nodrag and nopan for those purposes.13 The file input's click retains its default action, while dragover still calls preventDefault() to allow dropping files. The drop handler also prevents the browser from handling the dropped file itself.7
This complete example assumes a browser-rendered React component, the default React Flow utility-class names, and an onFiles callback responsible for validation and uploading. Any ancestor handler that cancels file-input clicks must first be removed or narrowed as shown above:
import { useRef } from 'react';
export function FileChooser({ onFiles }: { onFiles: (files: File[]) => void }) {
const inputRef = useRef<HTMLInputElement>(null);
return (
<div
className="nodrag nopan"
onDragOver={(event)=> {
event.preventDefault();
event.stopPropagation();
}}
onDrop={(event)=> {
event.preventDefault();
event.stopPropagation();
const files= Array.from(event.dataTransfer.files);
if (files.length) onFiles(files);
}}
>
<button
type="button"
onClick={(event)=> {
event.stopPropagation();
inputRef.current?.click();
}}
>
Choose files
</button>
<span> or drop files here</span>
<input
ref={inputRef}
type="file"
multiple
style={{ display: 'none' }}
onClick={(event)=> event.stopPropagation()}
onChange={(event)=> {
const files= Array.from(event.currentTarget.files ?? []);
event.currentTarget.value= ''; // Allow selecting the same file again.
if (files.length) onFiles(files);
}}
/>
</div>
);
}
The button supplies keyboard activation and has an explicit non-submit type. The input is its sibling, so its click does not re-enter the button handler. The selection and drop paths both pass File[] to the same callback. A canceled selection does not start an upload, and clearing the input after copying its files allows another selection of the same file.
The TypeScript excerpt has been checked for syntax and types. For integration, check mouse and keyboard activation, selecting the same file twice, canceling the picker, dropping files, and dragging or connecting the surrounding node. Each action should retain its own behavior: opening the picker should not drag the node, and dropping a file should not navigate the page.
The rule I now use is specific: preserve the file input click's default action, stop propagation only where needed, and retain default cancellation for drag-and-drop events. That gives the upload control a clear boundary inside the workflow editor. One call to .click() is enough once its picker action is allowed to run.
References
Footnotes
-
CaiBorui & AI assistant. (2025, March; month supplied by the author). FileNode file-picker debugging [Author-supplied conversation transcript; assistant platform and exact date not independently established]. Question following the full component; second answer, section 1, first paragraph. Supplied November 17, 2026. Selected original wording. ↩ ↩2 ↩3
-
CaiBorui. (2025, March 5). Fixing File Input Overlap Issue [Selected local conversation prompts]. Cursor. Session
c06230cb-85a6-4cf4-a5ed-1deecaa8d942, messages 1, 5, 7, 11, 15, 17, and 19. Archived prompts and timing metadata. Verified November 17, 2026, through read-only access to the legacy inlineconversationincursorDiskKV. Following assistant request times are proximity markers; message 20's response body is empty in the inspected record. ↩ ↩2 ↩3 ↩4 ↩5 -
caiborui [S2thend]. (2025, March 6). New ui for file upload node [Commit
96d2d625]. GitHub, puppyone-ai/puppyone-cloud. Changes toPuppyUpload.tsxandFileNode.tsx. https://github.com/puppyone-ai/puppyone-cloud/commit/96d2d625507102e38f17e2fe844e7542a941f2bd ↩ ↩2 -
caiborui [S2thend]. (2025, March 6). PuppyUpload.tsx [Source code at commit
96d2d625]. GitHub, puppyone-ai/puppyone-cloud. Lines 125–143, portaled file input; initiating click at lines 32–36. https://github.com/puppyone-ai/puppyone-cloud/blob/96d2d625507102e38f17e2fe844e7542a941f2bd/PuppyFlow/app/components/misc/PuppyUpload.tsx#L125-L143 ↩ -
React. (n.d.). createPortal. React documentation. “Caveats,” first bullet; “Rendering to a different part of the DOM.” Retrieved November 17, 2026, from https://react.dev/reference/react-dom/createPortal#caveats ↩
-
MDN contributors. (n.d.). HTMLElement: click() method. MDN Web Docs. Opening description. Retrieved November 17, 2026, from https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click ↩
-
MDN contributors. (n.d.). Using files from web applications. MDN Web Docs. “Using hidden file input elements using the click() method.” Retrieved November 17, 2026, from https://developer.mozilla.org/en-US/docs/Web/API/File_API/Using_files_from_web_applications#using_hidden_file_input_elements_using_the_click_method ↩ ↩2
-
MDN contributors. (n.d.). Event: stopPropagation() method. MDN Web Docs. Opening description. Retrieved November 17, 2026, from https://developer.mozilla.org/en-US/docs/Web/API/Event/stopPropagation ↩ ↩2
-
MDN contributors. (n.d.). Event: preventDefault() method. MDN Web Docs. Opening description and “Notes.” Retrieved November 17, 2026, from https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault ↩ ↩2
-
WHATWG. (n.d.). HTML Living Standard: The input element. “Show the picker, if applicable” algorithm, steps 1–3. Retrieved November 17, 2026, from https://html.spec.whatwg.org/multipage/input.html#show-the-picker,-if-applicable ↩
-
MDN contributors. (n.d.). <input type="file">. MDN Web Docs. “Detecting cancellations.” Retrieved November 17, 2026, from https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/file#detecting_cancellations ↩
-
CaiBorui. (2026, November 17). File-picker click behavior: isolated browser checks [Newly authored verification fixture and results]. Chromium 138.0.7204.23, headless, via Playwright. Script; observations. This fixture is separate from the March 2025 application. ↩
-
xyflow. (n.d.). Utility classes. React Flow documentation. “nodrag” and “nopan.” Retrieved November 17, 2026, from https://reactflow.dev/learn/customization/utility-classes ↩