Skip to content

Commit 60fca40

Browse files
fix: rich text link element not validating on create (#3014)
1 parent 733fc0b commit 60fca40

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/admin/components/forms/field-types/RichText/elements/link/LinkDrawer/baseFields.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ export const getBaseFields = (config: Config): Field[] => [
4646
type: 'text',
4747
required: true,
4848
admin: {
49-
condition: ({ linkType, url }) => {
50-
return (typeof linkType === 'undefined' && url) || linkType === 'custom';
51-
},
49+
condition: ({ linkType }) => linkType !== 'internal',
5250
},
5351
},
5452
{

test/fields/e2e.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,27 @@ describe('fields', () => {
477477
}
478478

479479
describe('toolbar', () => {
480+
test('should run url validation', async () => {
481+
await navigateToRichTextFields();
482+
483+
// Open link drawer
484+
await page.locator('.rich-text__toolbar button:not([disabled]) .link').first().click();
485+
486+
// find the drawer
487+
const editLinkModal = await page.locator('[id^=drawer_1_rich-text-link-]');
488+
await expect(editLinkModal).toBeVisible();
489+
490+
// Fill values and click Confirm
491+
await editLinkModal.locator('#field-text').fill('link text');
492+
await editLinkModal.locator('label[for="field-linkType-custom"]').click();
493+
await editLinkModal.locator('#field-url').fill('');
494+
await wait(200);
495+
await editLinkModal.locator('button[type="submit"]').click();
496+
const errorField = await page.locator('[id^=drawer_1_rich-text-link-] .render-fields > :nth-child(3)');
497+
const hasErrorClass = await errorField.evaluate(el => el.classList.contains('error'));
498+
expect(hasErrorClass).toBe(true);
499+
});
500+
480501
test('should create new url custom link', async () => {
481502
await navigateToRichTextFields();
482503

0 commit comments

Comments
 (0)