Skip to content

fix(booking-page): hide duplicate phone fields for attendee phone location#29761

Open
akshitj11 wants to merge 3 commits into
calcom:mainfrom
akshitj11:fix/booking-page-hide-duplicate-phone-23117
Open

fix(booking-page): hide duplicate phone fields for attendee phone location#29761
akshitj11 wants to merge 3 commits into
calcom:mainfrom
akshitj11:fix/booking-page-hide-duplicate-phone-23117

Conversation

@akshitj11

@akshitj11 akshitj11 commented Jul 13, 2026

Copy link
Copy Markdown

What does this PR do?

When an event type uses Attendee phone as the location and also has additional phone booking questions, the booking page showed duplicate phone inputs — the same data point collected twice.

This PR hides duplicate phone fields when location is set to attendee phone and syncs the phone value from the location field into other phone responses before submit. Logic is extracted to shouldHideDuplicatePhoneField with unit tests.

Visual Demo (For contributors especially)

A visual demonstration is strongly recommended, for both the original and new change (video / image - any one).

Video Demo (if applicable):

  • Record the booking form: select Attendee phone as location with an extra phone question configured. Before: two phone inputs. After: one phone input; submitted booking contains the correct phone value.

Image Demo (if applicable):

  • Side-by-side screenshot: before (duplicate phone fields) vs after (single phone input when location is attendee phone).

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox. (N/A)
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • Are there environment variables that should be set?
    • None.
  • What are the minimal test data to have?
    • Event type with location = Attendee phone and an additional phone booking question.
  • What is expected (happy path) to have (input and output)?
    • Input: open booking page, select Attendee phone, enter a number in the location phone field, submit.
    • Output: only one phone input visible; booking stores the phone value correctly.
  • Any other important info that could help to test that PR
    • Run: yarn vitest run apps/web/modules/bookings/components/BookEventForm/phoneFieldUtils.test.ts (5 tests pass).

…ation

When location is attendee phone, sync and hide other phone booking
questions so users are not prompted for the same number twice.

Fixes calcom#23117
@github-actions github-actions Bot added booking-page area: booking page, public booking page, booker Low priority Created by Linear-GitHub Sync 🧹 Improvements Improvements to existing features. Mostly UX/UI labels Jul 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Welcome to Cal.diy, @akshitj11! Thanks for opening this pull request.

A few things to keep in mind:

  • This is Cal.diy, not Cal.com. Cal.diy is a community-driven, fully open-source fork of Cal.com licensed under MIT. Your changes here will be part of Cal.diy — they will not be deployed to the Cal.com production app.
  • Please review our Contributing Guidelines if you haven't already.
  • Make sure your PR title follows the Conventional Commits format.

A maintainer will review your PR soon. Thanks for contributing!

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@akshitj11, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 26 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4fad5065-be01-477a-b17e-49066816ee27

📥 Commits

Reviewing files that changed from the base of the PR and between 46738ae and 903ebbf.

📒 Files selected for processing (1)
  • apps/web/modules/bookings/components/BookEventForm/BookingFields.tsx
📝 Walkthrough

Walkthrough

BookingFields now synchronizes trimmed phone location values into non-location phone responses and skips rendering those fields. The previous automatic smsReminderNumber synchronization and early hiding behavior was removed, allowing its remaining handling to execute normally.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR satisfies #23117 by hiding duplicate phone questions when attendee phone is selected while leaving other locations unaffected.
Out of Scope Changes check ✅ Passed The changes are limited to the phone-field fix, helper extraction, and tests, with no obvious unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly states the main change: hiding duplicate phone fields for the attendee phone location.
Description check ✅ Passed The description matches the implemented booking-page fix, including field hiding, sync behavior, and added tests.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
apps/web/modules/bookings/components/BookEventForm/BookingFields.tsx (1)

56-78: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consolidate the two phone-sync paths to avoid behavioral divergence.

There are now two sync mechanisms: syncPhoneFields (event-driven, with touched checks and dedup) and the render-time block (no touched checks, no dedup). This DRY violation means the two paths can silently diverge. Consolidate into a single function called from both the onValueChange handler and a useEffect watching locationResponse.

♻️ Proposed consolidation
+  const syncPhoneFromLocation = useCallback(
+    (locationValue: unknown) => {
+      const parsed = PhoneLocationSchema.safeParse(locationValue);
+      if (!parsed.success) return;
+      const phone = (parsed.data.optionValue ?? "").trim();
+      if (!phone || phone === lastSyncedPhoneRef.current) return;
+
+      otherPhoneFieldNames.forEach((name) => {
+        const targetTouched = !!(formState.touchedFields as TouchedFields)?.responses?.[name];
+        if (!targetTouched) {
+          setValue(`responses.${name}`, phone, {
+            shouldDirty: false,
+            shouldValidate: false,
+          });
+        }
+      });
+
+      lastSyncedPhoneRef.current = phone;
+    },
+    [otherPhoneFieldNames, formState.touchedFields, setValue]
+  );
+
+  useEffect(() => {
+    syncPhoneFromLocation(locationResponse);
+  }, [locationResponse, syncPhoneFromLocation]);

Then use syncPhoneFromLocation in the onValueChange handler and remove the inline setValue from the render block.

Also applies to: 154-168

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web/modules/bookings/components/BookEventForm/BookingFields.tsx` around
lines 56 - 78, Consolidate the phone synchronization logic into a single
function named syncPhoneFromLocation, preserving the existing parsing,
deduplication, and touched-field checks. Call this function from both the
location onValueChange handler and the useEffect watching locationResponse, and
remove the render-time inline setValue synchronization block.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/web/modules/bookings/components/BookEventForm/BookingFields.tsx`:
- Around line 161-165: Update the render-time phone field synchronization near
setValue to respect formState.touchedFields, matching syncPhoneFields behavior.
Only set responses.${field.name} when the field has not been touched, while
preserving the existing non-empty phone condition and setValue options.
- Around line 154-168: Move the phone response synchronization out of the
fields.map render path in BookingFields and into a useEffect that watches
locationResponse (and the relevant field data). Preserve the existing
conditions, trimmed phone value, setValue options, and return null behavior so
the duplicated phone field remains hidden during render.

---

Nitpick comments:
In `@apps/web/modules/bookings/components/BookEventForm/BookingFields.tsx`:
- Around line 56-78: Consolidate the phone synchronization logic into a single
function named syncPhoneFromLocation, preserving the existing parsing,
deduplication, and touched-field checks. Call this function from both the
location onValueChange handler and the useEffect watching locationResponse, and
remove the render-time inline setValue synchronization block.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c5c86aca-8537-437c-adfb-b9067e869ca9

📥 Commits

Reviewing files that changed from the base of the PR and between f004349 and 92a10d2.

📒 Files selected for processing (1)
  • apps/web/modules/bookings/components/BookEventForm/BookingFields.tsx

Comment thread apps/web/modules/bookings/components/BookEventForm/BookingFields.tsx Outdated
Comment thread apps/web/modules/bookings/components/BookEventForm/BookingFields.tsx Outdated
Extract shouldHideDuplicatePhoneField helper and cover attendee-phone
location cases so duplicate phone inputs stay hidden on the booking form.
@pull-request-size pull-request-size Bot added size/M and removed size/S labels Jul 13, 2026
Consolidate phone field sync into syncPhoneFromLocation with touched-field
checks and hide duplicate phone fields during render only.
@pull-request-size pull-request-size Bot added size/L and removed size/M labels Jul 13, 2026
@akshitj11

Copy link
Copy Markdown
Author

CodeRabbit fixes pushed. Please add the run-ci label. Thanks.

@github-actions

Copy link
Copy Markdown
Contributor

This PR has been marked as stale due to inactivity. If you're still working on it or need any help, please let us know or update the PR to keep it active.

@github-actions github-actions Bot added the Stale label Jul 21, 2026
@akshitj11

Copy link
Copy Markdown
Author

CodeRabbit feedback addressed in commits 46738aef and 903ebbf0:

  • Phone sync moved out of render into useEffect via syncPhoneFromLocation
  • Touched-field protection preserved during sync
  • Duplicate phone fields hidden via shouldHideDuplicatePhoneField helper with unit tests

Please add the run-ci label when convenient. Thanks!

@github-actions github-actions Bot removed the Stale label Jul 22, 2026
@CLAassistant

CLAassistant commented Jul 23, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

booking-page area: booking page, public booking page, booker 🧹 Improvements Improvements to existing features. Mostly UX/UI Low priority Created by Linear-GitHub Sync size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Asking for the phone number in the booking form with the attendee phone number set as the location results in two phone number fields

2 participants