This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Yew router when pushing history breaks form submits #2331
Comments
Tested on master rev |
@Firstyear I dont think ...
<form
onsubmit={ ctx.link().callback(|e| {
e.prevent_default();
AppMsg::ChangeState
} ) }
>
...
</form> |
Also im not sure what is going on here https://github.com/Firstyear/yew-sandbox/blob/main/src/manager.rs#L28 |
There are no examples of redirect on https://docs.rs/yew-router/latest/yew_router/ which is why I didn't know this existed. Everything refers to pushing history.
With the changes you suggested, this still doesn't work with push history. Main of the repro has been updated to show this.
If anything removing the onaction actually causes more issues because then on the second form submit, it doesn't seem to invoke the onsubmit handler and then triggers the tradition submit which causes the route to bypass the yew router code causing a 404. Using |
Tested in chrome 96.0.4664.110 (Official Build) (x86_64) as well now. |
@Firstyear Ok sorry i completely missed what you are trying to do here. Dont use forms with submit buttons + push_route to navigate between pages. Try using Unless this is just a simplification and in real code you have to navigate on submit press, then idk how to help. |
Here are the docs: https://yew.rs/docs/concepts/router#navigation |
2 more things regarding with your setup: ctx.link()
.history()
.expect_throw("failed to read history")
.back();
|
Please ask further questions in Discussions tab or in our discord. I am closing this as this is not an issue that needs to be worked on. |
The thing is this previously worked with yew-router, so it's a regression actually. It also works if you don't use the router API and just signal for the components to be swapped. It also breaks if you remove the form, and just use the button as per the example of "mycomponent". See the updated commits to the repro. Using "Link" however works, which confuses me even more. The reason I wanted to use the form/submit is to allow an autofocus to the element so the user can press "enter" to proceed. And yes, I have the miniserve now working in spa mode so that the route is not 404'ing. |
Ok im not sure how to handle this issue, Could you look into this @futursolo ? |
No no sry i forgot this issue is related with his env setup |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Problem
When a form is submitted that triggers a yew router push_history event, and subsequent form that is rendered by yew is unable to be submitted.
Steps To Reproduce
Steps to reproduce the behavior:
To reproduce this, I have provided a minimised example in the following repository:
https://github.com/Firstyear/yew-sandbox
Expected behavior
Pushing a route to the history to change pages with yew_router should not break form submissions.
Screenshots
Environment:
Questionnaire
The text was updated successfully, but these errors were encountered: