File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
packages/react-dom/src/__tests__ Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -1670,6 +1670,37 @@ describe('ReactDOMForm', () => {
16701670 expect ( divRef . current . textContent ) . toEqual ( 'Current username: acdlite' ) ;
16711671 } ) ;
16721672
1673+ it ( 'parallel form submissions do not throw' , async ( ) => {
1674+ const formRef = React . createRef ( ) ;
1675+ let resolve = null ;
1676+ function App ( ) {
1677+ async function submitForm ( ) {
1678+ Scheduler . log ( 'Action' ) ;
1679+ if ( ! resolve ) {
1680+ await new Promise ( res => {
1681+ resolve = res ;
1682+ } ) ;
1683+ }
1684+ }
1685+ return < form ref = { formRef } action = { submitForm } /> ;
1686+ }
1687+ const root = ReactDOMClient . createRoot ( container ) ;
1688+ await act ( ( ) => root . render ( < App /> ) ) ;
1689+
1690+ // Start first form submission
1691+ await act ( async ( ) => {
1692+ formRef . current . requestSubmit ( ) ;
1693+ } ) ;
1694+ assertLog ( [ 'Action' ] ) ;
1695+
1696+ // Submit form again while first form action is still pending
1697+ await act ( async ( ) => {
1698+ formRef . current . requestSubmit ( ) ;
1699+ resolve ( ) ; // Resolve the promise to allow the first form action to complete
1700+ } ) ;
1701+ assertLog ( [ 'Action' ] ) ;
1702+ } ) ;
1703+
16731704 it (
16741705 'requestFormReset works with inputs that are not descendants ' +
16751706 'of the form element' ,
You can’t perform that action at this time.
0 commit comments