fix: form input not being saved after "back" (#11540)
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
This commit is contained in:
parent
919066222b
commit
ce13350d5d
|
@ -252,6 +252,23 @@ test.describe("prefill", () => {
|
|||
});
|
||||
});
|
||||
|
||||
test("Persist the field values when going back and coming back to the booking form", async ({
|
||||
page,
|
||||
users,
|
||||
}) => {
|
||||
await page.goto("/pro/30min");
|
||||
await selectFirstAvailableTimeSlotNextMonth(page);
|
||||
await page.fill('[name="name"]', "John Doe");
|
||||
await page.fill('[name="email"]', "john@example.com");
|
||||
await page.fill('[name="notes"]', "Test notes");
|
||||
await page.click('[data-testid="back"]');
|
||||
|
||||
await selectFirstAvailableTimeSlotNextMonth(page);
|
||||
await expect(page.locator('[name="name"]')).toHaveValue("John Doe");
|
||||
await expect(page.locator('[name="email"]')).toHaveValue("john@example.com");
|
||||
await expect(page.locator('[name="notes"]')).toHaveValue("Test notes");
|
||||
});
|
||||
|
||||
test("logged out", async ({ page, users }) => {
|
||||
await page.goto("/pro/30min");
|
||||
|
||||
|
|
|
@ -461,7 +461,10 @@ function useInitialFormValues({
|
|||
const session = useSession();
|
||||
useEffect(() => {
|
||||
(async function () {
|
||||
if (Object.keys(formValues).length) return formValues;
|
||||
if (Object.keys(formValues).length) {
|
||||
setDefaultValues(formValues);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!eventType?.bookingFields) {
|
||||
return {};
|
||||
|
|
Loading…
Reference in New Issue
Block a user