fix(richtext-lexical): enable select inputs with ctrl+a or cmd+a (#12453)

Fixes #6871

To review this PR, use `pnpm dev lexical` and the auto-created document
in the `lexical fields` collection. Select any input within the blocks
and press `cmd+a`. The selection should contain the entire input.

I made sure that `cmd+a` still works fine inside the editor but outside
of inputs.
This commit is contained in:
Germán Jabloñski
2025-05-30 18:28:51 -03:00
committed by GitHub
parent 836fd86090
commit 89ced5ec6b
6 changed files with 56 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
import type { MigrateDownArgs, MigrateUpArgs} from '@payloadcms/db-postgres';
import type { MigrateDownArgs, MigrateUpArgs } from '@payloadcms/db-postgres'
import { sql } from '@payloadcms/db-postgres'

View File

@@ -62,6 +62,24 @@ describe('Lexical Fully Featured', () => {
const paragraph = lexical.editor.locator('> p')
await expect(paragraph).toHaveText('')
})
test('ControlOrMeta+A inside input should select all the text inside the input', async ({
page,
}) => {
const lexical = new LexicalHelpers(page)
await lexical.editor.first().focus()
await page.keyboard.type('Hello')
await page.keyboard.press('Enter')
await lexical.slashCommand('block')
await page.locator('#field-someText').first().focus()
await page.keyboard.type('World')
await page.keyboard.press('ControlOrMeta+A')
await page.keyboard.press('Backspace')
const paragraph = lexical.editor.locator('> p').first()
await expect(paragraph).toHaveText('Hello')
await expect(page.getByText('World')).toHaveCount(0)
})
test('text state feature', async ({ page }) => {
await page.keyboard.type('Hello')
await page.keyboard.press('ControlOrMeta+A')