Fix content type validation in create page view (#1205)

* Fix content type validation in create page view

* Update changelog

* Change disabled to valid
This commit is contained in:
Dawid Tarasiuk 2021-07-12 10:34:13 +02:00 committed by GitHub
parent 51dba9f43b
commit ab54fc6d68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

View file

@ -64,6 +64,7 @@ All notable, unreleased changes to this project will be documented in this file.
- Disable next step when no value selected in variant selector - #1218 by @orzechdev
- Fix order links on home page - #1219 by @jwm0
- Fix huge payload issue for plugins view - #1203 by @kamilpastuszka
- Fix content type validation in create page view - #1205 by @orzechdev
# 2.11.1

View file

@ -132,7 +132,7 @@ const PageDetailsPage: React.FC<PageDetailsPageProps> = ({
assignReferencesAttributeId={assignReferencesAttributeId}
onSubmit={onSubmit}
>
{({ change, data, handlers, hasChanged, submit }) => (
{({ change, data, valid, handlers, hasChanged, submit }) => (
<Container>
<AppHeader onBack={onBack}>
{intl.formatMessage(sectionNames.pages)}
@ -237,7 +237,7 @@ const PageDetailsPage: React.FC<PageDetailsPageProps> = ({
</div>
</Grid>
<SaveButtonBar
disabled={loading || !hasChanged}
disabled={loading || !hasChanged || !valid}
state={saveButtonBarState}
onCancel={onBack}
onDelete={page === null ? undefined : onRemove}

View file

@ -74,6 +74,7 @@ export interface PageUpdateHandlers {
export interface UsePageUpdateFormResult {
change: FormChange;
data: PageData;
valid: boolean;
handlers: PageUpdateHandlers;
hasChanged: boolean;
submit: () => void;
@ -223,9 +224,12 @@ function usePageForm(
? handleFormSubmit(getSubmitData(), handleSubmit, setChanged)
: onSubmit(getSubmitData());
const valid = !!opts.selectedPageType;
return {
change: handleChange,
data: getData(),
valid,
handlers: {
changeContent,
changeMetadata,