diff --git a/src/admin/components/forms/field-types/RichText/elements/link/LinkDrawer/baseFields.ts b/src/admin/components/forms/field-types/RichText/elements/link/LinkDrawer/baseFields.ts index 7bba95f8f1..1065227682 100644 --- a/src/admin/components/forms/field-types/RichText/elements/link/LinkDrawer/baseFields.ts +++ b/src/admin/components/forms/field-types/RichText/elements/link/LinkDrawer/baseFields.ts @@ -46,9 +46,7 @@ export const getBaseFields = (config: Config): Field[] => [ type: 'text', required: true, admin: { - condition: ({ linkType, url }) => { - return (typeof linkType === 'undefined' && url) || linkType === 'custom'; - }, + condition: ({ linkType }) => linkType !== 'internal', }, }, { diff --git a/test/fields/e2e.spec.ts b/test/fields/e2e.spec.ts index c256e57abc..0183e92e22 100644 --- a/test/fields/e2e.spec.ts +++ b/test/fields/e2e.spec.ts @@ -477,6 +477,27 @@ describe('fields', () => { } describe('toolbar', () => { + test('should run url validation', async () => { + await navigateToRichTextFields(); + + // Open link drawer + await page.locator('.rich-text__toolbar button:not([disabled]) .link').first().click(); + + // find the drawer + const editLinkModal = await page.locator('[id^=drawer_1_rich-text-link-]'); + await expect(editLinkModal).toBeVisible(); + + // Fill values and click Confirm + await editLinkModal.locator('#field-text').fill('link text'); + await editLinkModal.locator('label[for="field-linkType-custom"]').click(); + await editLinkModal.locator('#field-url').fill(''); + await wait(200); + await editLinkModal.locator('button[type="submit"]').click(); + const errorField = await page.locator('[id^=drawer_1_rich-text-link-] .render-fields > :nth-child(3)'); + const hasErrorClass = await errorField.evaluate(el => el.classList.contains('error')); + expect(hasErrorClass).toBe(true); + }); + test('should create new url custom link', async () => { await navigateToRichTextFields();