Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set text does not clear the text by firing the right events #3

Open
codrin-bytex opened this issue Jul 17, 2018 · 1 comment
Open

Comments

@codrin-bytex
Copy link

There is an issue with the .setText method on the WebElement. It is using the .clear method.
Based on this resource:

Note that the events fired by this event may not be as you'd expect. In particular, we don't fire any keyboard or mouse events

Considering an input field. The .clear() method will do a simple operation element.value = '', but it will not fire any events so that the application internal state will change. The way React works is it will use the state (which is stored in-memory) and update the nodes with it.
At some point it will rerender everything; this means that the state is now back to the one we have in memory.

There is a delay(100) and a series of keystrokes: CTRL+A and then DELETE. The field currently has no value (since .clear was called) and no event will be fired again (because it's already empty).
If we adapt the code to not use .clear this would result in an "change" event where we could now listen to and update the internal state with "" as the value of the input.

This also means that we can remove those hackish delays as well.
I can make a PR to fix this; just let me know.

Cheers.

@tascape
Copy link
Owner

tascape commented Jul 29, 2023

The current code works well in Chrome.
What is the situation it does not work?

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

No branches or pull requests

2 participants