You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Calling Node#set with empty string doesn't trigger the input event #156
Hi, thank you for building this great gem, it's so nice not to have to go through selenium and chromedriver 🙏🏻
When switching to Cuprite, I noticed that calling Node#set with an empty string doesn't trigger the input event. In my app I'm using Stimulus to listen to input event on a search field, and triggering requests when the field value changes. I had code like this:
visit"/products"find("#query").set("Foo")# input event is correctly triggeredexpect(page).tohave_current_path("/products?q=Foo")find("#query").set("")# input event is not triggeredexpect(page).tohave_current_path("/products?q=")# it's still on /products?q=Foo
Here is a self-contained example showing the input event is not being triggered:
Is there some other idiomatic way for clearing the field? I noticed that Selenium triggers some special clearing when an empty string is passed in to Node#set.
@tomekchime I don't remember from the top of my head, I think I just triggered the input event manually, possibly by calling trigger(:input) on the node.
Fixed in #336 (same bug as #164): clearing a non-empty text field with node.set("") / fill_in "field", with: "" now dispatches an input event (inputType: "deleteContentBackward") before change, so the trigger(:input) workaround is no longer needed. It will ship in the next release; until then you can use main.
Activity
tomekchime commentedon Feb 21, 2024
This looks related to #238. Curious if you were able to find a workaround @janko?
janko commentedon Feb 21, 2024
@tomekchime I don't remember from the top of my head, I think I just triggered the
inputevent manually, possibly by callingtrigger(:input)on the node.route commentedon Oct 15, 2026
Fixed in #336 (same bug as #164): clearing a non-empty text field with
node.set("")/fill_in "field", with: ""now dispatches aninputevent (inputType: "deleteContentBackward") beforechange, so thetrigger(:input)workaround is no longer needed. It will ship in the next release; until then you can usemain.