mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 04:48:53 +00:00
fix(core): cannot input space at the beginning of a blank paragraph (#12166)
### TL:DR fix: cannot input space at the beginning of a blank paragraph > CLOSE BS-3427 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Improved space key handling in the editor: pressing space on an empty AI input now hides the AI panel and inserts a space character back into the editor. - **Bug Fixes** - Prevented the AI panel from processing empty input when space is pressed, ensuring smoother user experience. - **Tests** - Added an end-to-end test verifying that pressing space on an empty AI input hides the AI panel and inserts a space. - **Refactor** - Streamlined event handling logic for space key detection in the editor. - **Chores** - Enhanced editor content retrieval to optionally preserve whitespace while removing invisible characters. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -35,4 +35,20 @@ test.describe('AIBasic/Guidance', () => {
|
||||
await page.keyboard.press('Enter');
|
||||
await expect(page.locator('affine-ai-panel-widget')).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('should hide AI panel and insert space back to editor when space is pressed on empty input', async ({
|
||||
page,
|
||||
utils,
|
||||
}) => {
|
||||
await utils.editor.focusToEditor(page);
|
||||
await page.keyboard.press('Space');
|
||||
await expect(page.locator('affine-ai-panel-widget')).toBeVisible();
|
||||
|
||||
await page.keyboard.press('Space');
|
||||
await expect(page.locator('affine-ai-panel-widget')).not.toBeVisible();
|
||||
await expect(async () => {
|
||||
const content = await utils.editor.getEditorContent(page, false);
|
||||
expect(content).toBe(' ');
|
||||
}).toPass({ timeout: 5000 });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user