Skip to content

[DataForm]: The ModalContent component doesn't properly check for fields validity #73330

@jimjasson

Description

@jimjasson

Description

When a field uses a validity prop:

isValid: {
	required: true,
},

and it is edited via a modal:

layout: {
	type: 'panel' as const,
	openAs: 'modal',
},

then the user can click the Apply button even if the field value is not valid.

A fix here would be to disable the Apply button when the form is not valid. For example, by adding disabled={ ! isValid } in this Button:

<Button
variant="primary"
onClick={ onApply }
__next40pxDefaultSize
>
{ __( 'Apply' ) }
</Button>

Step-by-step reproduction instructions

  1. Create a field with:
isValid: {
	required: true,
},
  1. In the form, set its layout to:
layout: {
	type: 'panel' as const,
	openAs: 'modal',
},
  1. Add it to a DataForm.
  2. Click to edit it.
  3. Don't fill in a value -- notice that an error message shows up below the field.
  4. Notice that you are able to click the Apply button, bypassing any validity checks.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

Labels

[Feature] DataViewsWork surrounding upgrading and evolving views in the site editor and beyond[Package] DataViews/packages/dataviews[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions