Open ShpetimA opened 3 weeks ago
Verified on my Android device, unfortunately this happens because we actually allow the press event to go through if it is on a submit
type button: https://github.com/adobe/react-spectrum/blob/09ccc53e71a0c423fea04bd9f8a80a6a97b14787/packages/%40react-aria/interactions/src/usePress.ts#L528-L532 as per the assumption described here. Will have to see if there are any alternatives checks that could be made but I'm not sure if we have enough information in usePress to know when it would be appropriate to not prevent default, especially for form submit buttons
Now that i understand what is happening i can add some workaround in our codebases for example not using automatic submition if forms overlap but still as a temporary measure this should be included in the docs so that users can be informed of this behaviour.
Provide a general summary of the issue here
Press events triggering on next screen when routing with react router.
I am assuming this is the same issue #7026 that this tries to fix but i am still going to report it since it might help having another case added.
π€ Expected Behavior?
Whenever we click on a button on one screen and that button routes to a different route with the same layout it should not trigger the form submit event or the active browser event on the new button that appears.
π― Current Behavior
https://github.com/user-attachments/assets/832186cf-e33e-40d1-a5df-89cf779463b0
When in mobile simulated touch view or in mobile device (tested on android). If we have two buttons on different screens both with type 'submit' if we switch screens in react router and the layout of both buttons is the same it should not trigger the event of submitting on the next button.
π Possible Solution
No response
π¦ Context
No response
π₯οΈ Steps to Reproduce
Have two routes in react router without layout changes where two buttons overlap and have type submits and you can achieve this bug. If the second button only has type submit and no onPress handler it automatically submits the form if it does have a onPress handler then in doesn't trigger the onPress event but the button seems to get focused by the browser.
https://codesandbox.io/p/sandbox/flamboyant-euler-src8pf?file=%2Fsrc%2FFirstPage.tsx%3A15%2C1&workspaceId=aaa23462-9fa5-46e4-a903-63e99d72520b
Version
3.31.0
What browsers are you seeing the problem on?
Firefox, Chrome
If other, please specify.
No response
What operating system are you using?
Mac OS
π§’ Your Company/Team
No response
π· Tracking Issue
No response