Potential React Forms Limitation
NB: I asked Claude to generate this report while we were testing - it could be nonsense - it could be right! I'll let you decide :-)
Report Date: August 3, 2025 Testing Environment: PWA Development Reporter: AI Development Assistant (Claude) Application Context: Progressive Web App
Executive Summary
During testing of a React PWA application, we identified a critical limitation with Browser MCP's
browser_type tool when interacting with React controlled components. The tool successfully updates
the visual appearance of form inputs but fails to trigger the necessary JavaScript events that React
components depend on for state management.
Issue Description
Problem Statement
Browser MCP's browser_type function can visually populate HTML input fields, but it does not
trigger React's onChange events, causing controlled components to have inconsistent state between
visual appearance and internal component state.
Severity
High - This limitation prevents effective testing of React applications with controlled form components, which represents a significant portion of modern web applications.
Technical Details
Test Environment
- Application: PWA (Next.js 14.2.30 + React)
- Browser MCP Version: Latest (accessed via Cursor/Claude Desktop)
- Browser: Chrome
- Component Type: React controlled inputs with
valueandonChangeprops
Expected Behavior
When using browser_type on a React controlled input:
- Visual text should appear in the input field ✅ (Working)
- React's
onChangeevent should fire ❌ (Not working) - Component state should update to reflect the new value ❌ (Not working)
- Form validation should work with the updated state ❌ (Not working)
Actual Behavior
- ✅ Visual text appears correctly in input fields
- ❌ React
onChangehandlers are not triggered - ❌ Component state (
formData) remains empty/unchanged - ❌ Form validation fails due to empty state values
- ❌ Form submission appears to "not work" (validation prevents submission)
Code Example
React Component Structure
// Component state
const [formData, setFormData] = useState({
groundName: '',
shooterName: '',
});
// Input field implementation
<input
id='groundName'
type='text'
value={formData.groundName} // Controlled component
onChange={e => handleInputChange('groundName', e.target.value)}
placeholder='Enter ground name'
/>
// State update handler
const handleInputChange = (field: string, value: string) => {
console.log('Input changed:', field, value); // This never fires with Browser MCP
setFormData(prev => ({
...prev,
[field]: value,
}));
};
Browser MCP Usage
// This command visually fills the field but doesn't trigger onChange
await browser_type({
element: 'Shooting Ground textbox',
ref: 's2e35',
text: 'Test Ground',
submit: false,
});
Root Cause Analysis
Browser MCP appears to directly manipulate the DOM input value without dispatching the necessary JavaScript events that React components listen for. React controlled components require specific event patterns to maintain their internal state.
Missing Events
The following events are likely not being triggered:
inputeventchangeevent- React's synthetic
onChangeevent - Potential
focus/blurevents
Impact Assessment
Testing Limitations
- React Applications: Cannot effectively test form submission workflows
- Form Validation: Validation logic cannot be tested as intended
- State Management: Component state inconsistencies prevent realistic testing
- User Experience: Testing doesn't reflect actual user interaction patterns
Affected Use Cases
- E-commerce checkout forms
- User registration/login forms
- Data entry applications
- Progressive Web Apps with offline forms
- Any React application using controlled components
Recommended Solutions
Short-term Workaround
For developers using Browser MCP with React applications:
- Bypass Validation for Testing:
// Temporarily disable validation to test other aspects
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
// Skip validation for Browser MCP testing
// if (!validateForm()) return;
// Continue with submission logic
};
- Add Debug Fallbacks:
// Use hardcoded values when state is empty (Browser MCP scenario)
const getFormData = () => {
if (!formData.groundName && !formData.shooterName) {
return {
groundName: 'Browser MCP Test Ground',
shooterName: 'Browser MCP Test User',
};
}
return formData;
};
Long-term Browser MCP Enhancement
Recommended Feature: Enhanced React Support
Add a new parameter to browser_type:
browser_type({
element: 'input element',
ref: 'element_ref',
text: 'text to type',
submit: false,
triggerEvents: true, // NEW: Trigger React-compatible events
});
Technical Implementation Suggestions
When triggerEvents: true:
- Dispatch Input Events:
// After setting input value
const inputEvent = new Event('input', { bubbles: true });
const changeEvent = new Event('change', { bubbles: true });
element.dispatchEvent(inputEvent);
element.dispatchEvent(changeEvent);
- React-Specific Event Simulation:
// Trigger React's synthetic event system
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(
window.HTMLInputElement.prototype,
'value'
).set;
nativeInputValueSetter.call(element, text);
const event = new Event('input', { bubbles: true });
element.dispatchEvent(event);
- Focus/Blur Simulation:
element.focus();
// Set value and trigger events
element.blur();
Test Cases for Verification
Basic React Form Test
- Create a simple React form with controlled inputs
- Use Browser MCP to fill inputs
- Verify component state updates correctly
- Test form submission with validation
Complex Scenarios
- Conditional Validation: Forms with dynamic validation rules
- Multi-Step Forms: State persistence across form steps
- Real-time Updates: Components that update as user types
- Cross-Component Communication: Forms that update other components
Conclusion
This limitation significantly impacts Browser MCP's utility for testing modern React applications.
The visual success of browser_type can be misleading, as it creates a false appearance of working
functionality while the underlying application state remains unchanged.
Implementing enhanced event triggering would greatly improve Browser MCP's compatibility with React and other modern JavaScript frameworks that rely on controlled components and event-driven state management.
This report is based on extensive testing during development of a React PWA application and represents real-world usage patterns that Browser MCP users are likely to encounter.
Browser MCP has been completely rewritten, so most open issues should now be resolved. I'm closing this issue as part of a cleanup. If the problem persists on the latest version, you're welcome to file a new issue.