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

How to trigger onchange event without submitting the form? #192

Open
amiyatulu opened this issue Jan 28, 2024 · 2 comments
Open

How to trigger onchange event without submitting the form? #192

amiyatulu opened this issue Jan 28, 2024 · 2 comments
Labels
question Further information is requested

Comments

@amiyatulu
Copy link

amiyatulu commented Jan 28, 2024

let transfer_balance = self
     .driver
      .find(By::XPath("//*[contains(@name, 'transfer_balance')]"))
      .await?;
transfer_balance.send_keys(amount.to_string()).await?;
transfer_balance.send_keys(Key::Return.to_string()).await?;

transfer_balance.send_keys(Key::Return.to_string()).await?;

The Return key submits the form instead of just triggering onchange. How to solve the issue?

html code in yew

       <form onsubmit={onsubmit}>
            <div class="mb-3">
            <label for="Destination Account" class="form-label">{"Destination Account Address:"}</label>
            <input name={"destination_account"} type="text" class={"form-control"} required={true} onchange={dest_account_onchanged}/>
            </div>
            <div class="mb-3">
            <label for="Transfer Balance" class="form-label">{"Transfer Balance:"}</label>
            <input name={"transfer_balance"} type="number" class={"form-control"} required={true} onchange={transfer_balance_onchanged}/>
            </div>
            if let Some(_value) = *spinner {
                <input type="submit" value="Submit" disabled={true}  id="tranfer-balance-submit"/>
                <Icon icon_id={IconId::FontAwesomeSolidSpinner} />
            } else {
                <input type="submit" value="Submit" id="tranfer-balance-submit"/>
            }

          </form>
@amiyatulu
Copy link
Author

amiyatulu commented Jan 28, 2024

Changed to oninput={}, and removed Key::Return, it works now. But not sure, how to do it, if such situation occurs in someone else code.

@stevepryde
Copy link
Owner

Is there a way for a user of your app to do it? If so, try automating that action.
Or you might be able to trigger it by running some custom JS via execute_script().
https://docs.rs/thirtyfour/0.32.0-rc.9/thirtyfour/session/handle/struct.SessionHandle.html#method.execute

@stevepryde stevepryde added the question Further information is requested label Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants