Skip to content

fix: destructure formState properties for proper Proxy subscription - #6

Open
deepshekhardas wants to merge 7 commits into
mainfrom
fix/formstate-proxy-subscription
Open

deepshekhardas wants to merge 7 commits into
mainfrom
fix/formstate-proxy-subscription

Conversation

@deepshekhardas

@deepshekhardas deepshekhardas commented May 13, 2026

Copy link
Copy Markdown
Owner

Problem

Components accessing formState properties directly (e.g., formState.errors, formState.isDirty) don't re-render when values change because react-hook-form wraps formState with a Proxy.

According to react-hook-form's documentation, the Proxy subscription only works when properties are destructured at the component level before render.

Fix

Destructure formState properties at component level to ensure proper Proxy subscription and correct re-rendering.

Changes:

  • packages/ui/components/form/inputs/Input.tsx: Extract errors from formState before using

Refs: calcom#25208


Summary by cubic

Adds a minimum cancellation notice to Event Types with a simple UI (“always disable” or “disable when less than X minutes”) and enforces it in the app and API. Also rolls back bookings when all calendar syncs fail, lets hosts bypass minimum booking notice when rescheduling, and fixes form re-renders by destructuring formState from react-hook-form.

  • New Features

    • Minimum cancellation notice on Event Types via DisableCancellingController.
    • Client checks use isWithinMinimumCancellationNotice and hide the cancel action; server rejects cancels inside the window; adds minimumCancellationNotice to EventType.
  • Bug Fixes

    • Roll back and cancel bookings when all calendar create/reschedule integrations fail, with clear errors.
    • Hosts can reschedule their own bookings even within minimum booking notice.
    • Destructure formState props across components to ensure Proxy subscription and re-renders (Input, address fields, HintOrErrors, AvailabilitySettings, EventTypePlatformWrapper, AppleConnect, TeamEventTypeForm, CreateEventTypeForm), including touchedFields, errors, isSubmitted, and dirtyFields where used.

Written for commit f19a6d4. Summary will update on new commits.

deepshekhardas added 7 commits May 11, 2026 14:38
- Add minimumCancellationNotice field to EventType model and types
- Create DisableCancellingController component with UI for setting notice period
- Add server-side validation in handleCancelBooking
- Add client-side validation in booking actions and booking details page
- Add isWithinMinimumCancellationNotice utility function

Closes calcom#15647
When all calendar integrations (Google Calendar, Outlook, etc.) fail to create
events, the booking is now rolled back and cancelled instead of being left
as ACCEPTED with no calendar event. This prevents data inconsistency where
bookings appear confirmed but have no corresponding calendar event.

- Added rollback logic for new bookings when all calendar creation fails
- Added rollback logic for rescheduling when all calendar updates fail
- Updated error messages to be more user-friendly

Closes calcom#28397
When a host reschedules their own booking, the minimum booking notice
restriction is now ignored. This allows hosts to reschedule last-minute
(e.g., 7pm meeting rescheduled at 6:40pm) without being blocked.

The minimum notice still applies to regular bookers/attendees.

Closes calcom#18980
Issue: Components accessing formState properties directly (e.g., formState.errors, formState.isDirty) don't re-render when values change because react-hook-form wraps formState with a Proxy.

Fix: Destructure formState properties at component level to ensure proper Proxy subscription and correct re-rendering.

Refs: calcom#25208
- AvailabilitySettings.tsx: destructure isDirty from formState
- HintOrErrors.tsx: destructure errors from formState
- address/fields.tsx: destructure errors in InputField and TextAreaField

Refs: calcom#25208
- EventTypePlatformWrapper.tsx: errors, isSubmitting
- AppleConnect.tsx: isSubmitting
- TeamEventTypeForm.tsx: touchedFields

Refs: calcom#25208
- CreateEventTypeForm.tsx: touchedFields
- TeamEventTypeForm.tsx: errors
- HintOrErrors.tsx: isSubmitted, dirtyFields

Refs: calcom#25208
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant