diff --git a/.changeset/six-meals-lie.md b/.changeset/six-meals-lie.md new file mode 100644 index 0000000000..69f6b4c99e --- /dev/null +++ b/.changeset/six-meals-lie.md @@ -0,0 +1,8 @@ +--- +"@comet/cms-admin": patch +--- + +Fix link target validation in `ExternalLinkBlock` + +Previously, two different validation checks were used. +This resulted in an error when saving an invalid link target but no error message was shown. diff --git a/packages/admin/cms-admin/src/blocks/ExternalLinkBlock.tsx b/packages/admin/cms-admin/src/blocks/ExternalLinkBlock.tsx index df14ba3fa2..71b16f2c93 100644 --- a/packages/admin/cms-admin/src/blocks/ExternalLinkBlock.tsx +++ b/packages/admin/cms-admin/src/blocks/ExternalLinkBlock.tsx @@ -6,7 +6,7 @@ import { FormattedMessage } from "react-intl"; import { ExternalLinkBlockData, ExternalLinkBlockInput } from "../blocks.generated"; import { isLinkTarget } from "../validation/isLinkTarget"; -import { validateUrl } from "../validation/validateUrl"; +import { validateLinkTarget } from "../validation/validateLinkTarget"; type State = ExternalLinkBlockData; @@ -68,7 +68,7 @@ export const ExternalLinkBlock: BlockInterface validateUrl(url)} + validate={(url) => validateLinkTarget(url)} disableContentTranslation /> diff --git a/packages/admin/cms-admin/src/validation/validateLinkTarget.tsx b/packages/admin/cms-admin/src/validation/validateLinkTarget.tsx new file mode 100644 index 0000000000..a6a702762f --- /dev/null +++ b/packages/admin/cms-admin/src/validation/validateLinkTarget.tsx @@ -0,0 +1,10 @@ +import React from "react"; +import { FormattedMessage } from "react-intl"; + +import { isLinkTarget } from "./isLinkTarget"; + +export function validateLinkTarget(linkTarget: string) { + if (!isLinkTarget(linkTarget)) { + return ; + } +}