'Laravel Dusk field type() misses characters with React controlled input

Using the straightforward Dusk function type() to fill out an input, we see that only the first few characters get entered. Usually 3 or 4, it varies, but the rest get missed out every time.

$browser->type('input[name="myInput"]', "0123456789");

This results in e.g. '0123' or '012345'. Never gets up to 10 chars.

Using value() results in an empty input.

The input is a Controlled Component in React, i.e. the onChange event is triggering a state update which in turn is setting the value.

My guess is that this React behavior is surprising to Dusk, and is therefore causing this problem.

Any workaround would be gratefully received!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source