fix(ui): lexical was incorrectly set to readonly in blocks (#9237)

Fixes a bug introduced in `beta-131` that rendered Lexical fields as
read-only if they were within a block.
This commit is contained in:
James Mikrut
2024-11-15 17:47:26 -05:00
committed by GitHub
parent 30d66bf601
commit 131d1be8fc
5 changed files with 115 additions and 4 deletions

View File

@@ -65,6 +65,7 @@ describe('access control', () => {
let restrictedUrl: AdminUrlUtil
let unrestrictedURL: AdminUrlUtil
let readOnlyCollectionUrl: AdminUrlUtil
let richTextUrl: AdminUrlUtil
let readOnlyGlobalUrl: AdminUrlUtil
let restrictedVersionsUrl: AdminUrlUtil
let userRestrictedCollectionURL: AdminUrlUtil
@@ -80,6 +81,7 @@ describe('access control', () => {
url = new AdminUrlUtil(serverURL, slug)
restrictedUrl = new AdminUrlUtil(serverURL, fullyRestrictedSlug)
richTextUrl = new AdminUrlUtil(serverURL, 'rich-text')
unrestrictedURL = new AdminUrlUtil(serverURL, unrestrictedSlug)
readOnlyCollectionUrl = new AdminUrlUtil(serverURL, readOnlySlug)
readOnlyGlobalUrl = new AdminUrlUtil(serverURL, readOnlySlug)
@@ -147,6 +149,28 @@ describe('access control', () => {
})
})
describe('rich text', () => {
test('rich text within block should render as editable', async () => {
await page.goto(richTextUrl.create)
await page.locator('.blocks-field__drawer-toggler').click()
await page.locator('.thumbnail-card').click()
const richTextField = page.locator('.rich-text-lexical')
const contentEditable = richTextField.locator('.ContentEditable__root').first()
await expect(contentEditable).toBeVisible()
await contentEditable.click()
const typedText = 'Hello, this field is editable!'
await page.keyboard.type(typedText)
await expect(
page.locator('[data-lexical-text="true"]', {
hasText: exactText(typedText),
}),
).toHaveCount(1)
})
})
describe('collection — fully restricted', () => {
let existingDoc: ReadOnlyCollection