Skip to content

[pull] main from facebook:main #137

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

Merged
merged 1 commit into from
May 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions packages/react-dom/src/__tests__/ReactDOMForm-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,37 @@ describe('ReactDOMForm', () => {
expect(divRef.current.textContent).toEqual('Current username: acdlite');
});

it('parallel form submissions do not throw', async () => {
const formRef = React.createRef();
let resolve = null;
function App() {
async function submitForm() {
Scheduler.log('Action');
if (!resolve) {
await new Promise(res => {
resolve = res;
});
}
}
return <form ref={formRef} action={submitForm} />;
}
const root = ReactDOMClient.createRoot(container);
await act(() => root.render(<App />));

// Start first form submission
await act(async () => {
formRef.current.requestSubmit();
});
assertLog(['Action']);

// Submit form again while first form action is still pending
await act(async () => {
formRef.current.requestSubmit();
resolve(); // Resolve the promise to allow the first form action to complete
});
assertLog(['Action']);
});

it(
'requestFormReset works with inputs that are not descendants ' +
'of the form element',
Expand Down
Loading