diff --git a/packages/lexical-playground/__tests__/e2e/Hashtags.spec.mjs b/packages/lexical-playground/__tests__/e2e/Hashtags.spec.mjs index d85e906686b..924eda6f9bc 100644 --- a/packages/lexical-playground/__tests__/e2e/Hashtags.spec.mjs +++ b/packages/lexical-playground/__tests__/e2e/Hashtags.spec.mjs @@ -302,4 +302,47 @@ test.describe('Hashtags', () => { `, ); }); + + test('Should not break with multiple leading "#" #5636', async ({page}) => { + await focusEditor(page); + await page.keyboard.type('#hello'); + + await waitForSelector(page, '.PlaygroundEditorTheme__hashtag'); + + await assertHTML( + page, + html` +

+ + #hello + +

+ `, + ); + await assertSelection(page, { + anchorOffset: 6, + anchorPath: [0, 0, 0], + focusOffset: 6, + focusPath: [0, 0, 0], + }); + + await moveToEditorBeginning(page); + await page.keyboard.type('#'); + + await assertHTML( + page, + html` +

+ # + + #hello + +

+ `, + ); + }); });