Forms: Add form name modal to wp-build dashboard#47395
Conversation
When creating a new form from the wp-build forms dashboard, show a modal prompting the user to name their form before navigating to the editor. The form title is passed via URL parameter, and the editor's own naming modal is skipped when a title was already provided from the dashboard. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
There was a problem hiding this comment.
Pull request overview
Adds a “name your form” modal to the wp-build Forms dashboard create flow, passing the chosen name into the editor so the editor-side naming modal can be skipped when appropriate.
Changes:
- Introduces
showNameModalonCreateFormButton(default off) to optionally prompt for a name before creating a form. - Extends
useCreateForm.openNewFormto acceptformTitleand forwards it to wp-admin viapost_titlequery param. - Updates the editor’s
FormTitleModalto skip prompting whenpost_titleis present, and wires the same naming modal into the mobile actions dropdown.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/packages/forms/src/form-editor/plugins/form-title-modal.tsx | Skips editor naming modal when post_title is present in the URL. |
| projects/packages/forms/src/dashboard/wp-build/hooks/use-page-header-details.tsx | Adds mobile “Create a form” modal flow + enables modal for wp-build header buttons. |
| projects/packages/forms/src/dashboard/hooks/use-create-form.ts | Adds optional formTitle to build a post_title URL param. |
| projects/packages/forms/src/dashboard/components/create-form-button/index.tsx | Adds optional naming modal gating the create-form button. |
| projects/packages/forms/routes/forms/stage.tsx | Enables showNameModal for the wp-build “empty state” create button. |
| projects/packages/forms/changelog/update-form-wp-build-create-form | Changelog entry for the new modal behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const handleModalSave = useCallback( | ||
| async ( formName: string ) => { | ||
| await openNewForm( { | ||
| showPatterns, | ||
| formTitle: formName, | ||
| analyticsEvent: () => { | ||
| jetpackAnalytics.tracks.recordEvent( 'jetpack_wpa_forms_landing_page_cta_click', { | ||
| button: 'forms', | ||
| } ); | ||
| }, | ||
| } ), | ||
| } ); | ||
| }, |
There was a problem hiding this comment.
FormNameModal always passes a non-empty name to onSave (it falls back to "Untitled Form" when the input is empty). That means formTitle will always be truthy here, so useCreateForm will always append post_title=..., and the editor’s FormTitleModal will always skip showing—contradicting the intended behavior where submitting an empty name should allow the editor naming modal to appear. Consider updating the flow so an empty input results in no post_title param (e.g., add an option to FormNameModal to allow empty/undefined results, or pass through an empty string and only include post_title when the user actually entered a name).
There was a problem hiding this comment.
No we do want this to be the case otherwise we show the modal twice.
projects/packages/forms/src/dashboard/wp-build/hooks/use-page-header-details.tsx
Outdated
Show resolved
Hide resolved
projects/packages/forms/src/form-editor/plugins/form-title-modal.tsx
Outdated
Show resolved
Hide resolved
| const hasPostTitle = urlParams.has( 'post_title' ); | ||
|
|
||
| if ( isFormEditor && ! hasInnerBlocks && isNewForm && ! hasShown && ! hasPostTitle ) { |
There was a problem hiding this comment.
urlParams.has('post_title') treats post_title as present even if it’s empty (e.g. ?post_title=), and it will also skip the modal even when the value is just the default/placeholder. To avoid suppressing the editor naming modal unintentionally, consider using urlParams.get('post_title') and only skipping when the value is non-empty/meaningful.
| const hasPostTitle = urlParams.has( 'post_title' ); | |
| if ( isFormEditor && ! hasInnerBlocks && isNewForm && ! hasShown && ! hasPostTitle ) { | |
| const postTitle = urlParams.get( 'post_title' ); | |
| const hasMeaningfulPostTitle = | |
| typeof postTitle === 'string' && postTitle.trim() !== ''; | |
| if ( | |
| isFormEditor && | |
| ! hasInnerBlocks && | |
| isNewForm && | |
| ! hasShown && | |
| ! hasMeaningfulPostTitle | |
| ) { |
Code Coverage SummaryCoverage changed in 4 files.
Full summary · PHP report · JS report If appropriate, add one of these labels to override the failing coverage check:
Covered by non-unit tests
|
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| async ( formName: string ) => { | ||
| const trimmedName = formName.trim(); | ||
| if ( trimmedName ) { | ||
| await openNewForm( { formTitle: trimmedName } ); | ||
| } else { | ||
| await openNewForm( {} ); | ||
| } |
There was a problem hiding this comment.
handleCreateFormSave has an else branch intended to create a form without a title (so post_title is omitted), but FormNameModal always calls onSave with a non-empty fallback (trimmed input || "Untitled Form"). As a result trimmedName will always be truthy here and the else branch is effectively dead, and the editor’s FormTitleModal will always be skipped.
If you want the “Create with empty name -> show editor naming modal” behavior, FormNameModal needs an option to allow empty/undefined results (or a separate “Skip naming” action). Otherwise, simplify this handler and update the documented/testing expectations accordingly.
Screen.Recording.2026-02-27.at.4.35.22.PM.mov
Proposed changes
showNameModalprop toCreateFormButton(defaults tofalse) so the modal only appears in wp-build contextsuseCreateFormhook now accepts an optionalformTitleparameter, passed to the editor viapost_titleURL parameterFormTitleModalchecks for thepost_titleURL parameter and skips showing the duplicate naming modal when the user already named the form from the dashboardusePageHeaderDetailsto also use the form name modalOther information
All changes are scoped to
projects/packages/forms. The modal reuses the existingFormNameModalcomponent.Does this pull request change what data or activity we track or use?
No
Testing instructions
Enable
jetpack_forms_alphaand central form managementGo to the Forms dashboard (wp-build route)
Click "Create a form" — a modal should appear asking for the form name
Enter a name and click "Create" — you should be navigated to the form editor with the title set
Verify the editor's own naming modal does not appear (since you already named the form)
Go back to dashboard, click "Create a form" again, and click "Cancel" — modal should close without navigating
Click "Create a form" and click "Create" without entering a name — the editor should open and show its own naming modal
On mobile, use the dropdown menu's "Create a form" option — same modal behavior
Disable
jetpack_forms_alpha/ central form management and verify the old dashboard's "Create a form" button still works without showing a modal