Engineering · · 9 min read
React, Vue, and Angular form fields that break your tests (and how to fix each one)
Getting a plain text input to update in a controlled form is one problem. Custom dropdowns, date pickers, and file uploads are five different problems wearing the same trench coat — each one stores its value differently, and each one needs its own fix.
- Custom dropdowns — no value to set; you have to click the option.
- Date pickers — native inputs work with the native-setter fix; full calendar-popup pickers usually need a real click.
- File uploads — direct assignment is blocked by the browser; use a
DataTransferobject instead. - Checkbox / radio groups — toggle each input individually; don't assume a "select all" checkbox re-syncs itself.
- Autocomplete / tag inputs — type first to trigger the filter, then click the option that appears.
Jump straight to a field type, or read straight through:
input.value assignment fails on controlled components first — every fix below builds on that same native-setter technique.The short version: React, Vue, and Angular all keep the "real" value of an input in their own internal state, not in the DOM. A plain text field just needs that state updated correctly, which the native-setter technique handles. The five field types below are harder because the value isn't a simple string owned by one input — it's an object, a file, an array, or something that only changes in response to a specific user gesture. Here's what each one actually needs.
1. Custom dropdowns and selects
A native <select> has a real DOM value and the native-setter fix works on it exactly like a text input. The problem is that most production forms don't use a native select — they use react-select, MUI's Select, Angular Material's mat-select, or a hand-rolled version of the same pattern: a button that opens a floating list of options, none of which are a real <select><option> pair under the hood.
There is no single native setter to call here, because there's no native form control storing the value — it's plain component state, and that state only changes inside a click handler attached to each option. The only working fix is to reproduce the interaction a real user performs: open the dropdown, locate the option element that matches the target value (usually by its text content, since there's rarely a stable selector), and dispatch a real pointer/click event on it.
Watch for options rendered in a React portal — react-select and MUI append the option list to document.body, not inside the dropdown's own DOM subtree. Querying for options inside the visible field container will come back empty even while the list is open on screen.
2. Date pickers
This one splits into two genuinely different problems depending on what's actually rendered:
Native <input type="date"> — this is a real form control with a real value (in YYYY-MM-DD format regardless of how it displays to the user), so the native-setter technique works on it the same as any text input. No calendar UI to deal with.
Custom JS date pickers (react-datepicker, MUI's DatePicker, Angular Material's datepicker) — these pair a text input with a calendar popup, and the underlying value is usually stored as a Date object in component state, not a string. Typing text directly into the input may or may not work depending on whether the library parses free text against its expected format — some accept it, many silently ignore anything that doesn't match their internal mask. The reliable path is the same as the dropdown case: open the picker, navigate to the right month, and click the day cell.
3. File upload inputs
File inputs are the one field type on this list where the fix has nothing to do with React, Vue, or Angular — it's a browser security restriction that applies everywhere. Modern browsers make input.value read-only on <input type="file"> specifically so that a webpage can't silently populate a file field and trick a user into uploading something they didn't choose. Assigning to it directly does nothing, framework or no framework.
The sanctioned workaround is to construct the file entirely in memory and hand it to the input through the one API designed for this: DataTransfer.
const dt = new DataTransfer();
dt.items.add(new File(["content"], "test.png", { type: "image/png" }));
input.files = dt.files;
input.dispatchEvent(new Event("change", { bubbles: true }));
No file needs to exist on disk — the File object is built entirely in JavaScript. Two things trip people up here: forgetting that file inputs fire a change event, not input; and drag-and-drop upload zones, which usually aren't a real file input at all and need simulated dragenter/dragover/drop events carrying the same DataTransfer payload instead.
4. Checkbox and radio groups
A single controlled checkbox is genuinely simple — the native-setter fix applies to it exactly like a text input, since a checkbox's value is still just a DOM property (checked instead of value). The bug shows up specifically in groups: a set of checkboxes whose combined state lives in one array on the parent (selectedTags: ['a', 'b']), or a radio group where the framework itself enforces that only one input can be true.
Toggling one checkbox correctly updates that one input's own state, but it does nothing for sibling inputs — and it does nothing for any derived UI built on top of the group, like a "select all" checkbox that's supposed to reflect whether every item underneath it is checked. That derived state is computed separately (often in a useEffect, a Vue watcher, or an Angular computed signal), and it won't magically recalculate just because you clicked something — it recalculates because the framework's normal render cycle ran, which it will, but it's worth explicitly testing rather than assuming.
5. Autocomplete and tag inputs
Combobox-style fields (role="combobox" paired with role="listbox") — type-ahead search boxes, tag pickers, multi-select chips — combine two pieces of state: a text buffer for whatever's currently typed, and a separate committed list of selected items. This makes them a two-stage interaction rather than a single click or a single value assignment.
You can't select an option that hasn't rendered yet, and most of these components only render their filtered option list after receiving real input. So the working sequence is: use the native-setter technique to type into the text buffer (which also fires the input event that triggers the library's filtering logic), wait for the now-filtered listbox to appear, then click the matching option the same way you would for a plain custom dropdown.
The general approach, for any field you haven't seen before
New component libraries show up constantly, and you won't always recognize the pattern on sight. This four-step process works for identifying the right fix on anything:
<select>, <input type="date">) wearing custom CSS, or a fully custom widget built from <div>s and <button>s with no native control underneath at all?Common misconceptions
input.value is read-only on file inputs in every modern browser, for security reasons that have nothing to do with your framework. DataTransfer is the only supported path in.<select> once you know the trick."mat-select and Vue components with async-loaded option lists are the two that most often surprise people who assumed the React fix would just transfer over.Further reading
- Why form fillers break on React (and Vue, and Angular) forms — the native-setter technique this entire checklist builds on.
- A practical checklist for testing multilingual forms — the other class of bugs, specific to locale rather than framework.
FAQ
Auto Fill Fake Data handles the native-setter fix, checkbox groups, and autocomplete filtering automatically on every field it fills — no manual scripting required.
Install free — Chrome Web Store