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
- Create a field with:
isValid: {
required: true,
},
- In the form, set its layout to:
layout: {
type: 'panel' as const,
openAs: 'modal',
},
- Add it to a DataForm.
- Click to edit it.
- Don't fill in a value -- notice that an error message shows up below the field.
- 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.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.
Description
When a field uses a validity prop:
and it is edited via a 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 thisButton:gutenberg/packages/dataviews/src/dataform-layouts/panel/modal.tsx
Lines 115 to 121 in 4dc556a
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.