|
|
@@ -234,3 +234,30 @@ test('press escape when autocomplete menu is open, should close autocomplete men
|
|
|
expect(await block.isEditing()).toBe(true)
|
|
|
}
|
|
|
})
|
|
|
+
|
|
|
+test('press escape when link/image dialog is open, should restore focus to input', async ({ page, block }) => {
|
|
|
+ for (const [commandTrigger, modalName] of [['/link', 'commands']]) {
|
|
|
+ await createRandomPage(page)
|
|
|
+
|
|
|
+ // Open the action modal
|
|
|
+ await block.mustFill('')
|
|
|
+ await page.waitForTimeout(550)
|
|
|
+ for (const char of commandTrigger) {
|
|
|
+ await page.keyboard.type(char) // Type it one character at a time, because too quickly can fail to trigger it sometimes
|
|
|
+ }
|
|
|
+ await page.waitForTimeout(100)
|
|
|
+ await expect(page.locator(`[data-modal-name="${modalName}"]`)).toBeVisible()
|
|
|
+ await page.waitForTimeout(100)
|
|
|
+
|
|
|
+ // Press enter to open the link dialog
|
|
|
+ await page.keyboard.press('Enter')
|
|
|
+ await expect(page.locator(`[data-modal-name="input"]`)).toBeVisible()
|
|
|
+
|
|
|
+ // Press escape; should close link dialog and restore focus to the block textarea
|
|
|
+ await page.keyboard.press('Escape')
|
|
|
+ await page.waitForTimeout(100)
|
|
|
+ await expect(page.locator(`[data-modal-name="input"]`)).not.toBeVisible()
|
|
|
+ await page.waitForTimeout(1000)
|
|
|
+ expect(await block.isEditing()).toBe(true)
|
|
|
+ }
|
|
|
+})
|