🚸(frontend) ctrl+k modal not when editor is focused

ctrl+k interaction was as well used in the editor.
So if the user has a focus on the editor, we don't
open the searchmodal.
This commit is contained in:
Anthony LC
2025-03-13 14:54:49 +01:00
committed by Anthony LC
parent 313acf4f78
commit 20d32ecc4e
3 changed files with 43 additions and 0 deletions

View File

@@ -12,10 +12,15 @@ and this project adheres to
- 📝(doc) add publiccode.yml
## Changed
- 🚸(frontend) ctrl+k modal not when editor is focused #712
## Fixed
- 🐛(back) allow only images to be used with the cors-proxy #781
## [2.5.0] - 2025-03-18
## Added

View File

@@ -63,4 +63,35 @@ test.describe('Document search', () => {
listSearch.getByRole('option').getByText(doc2Title),
).toBeHidden();
});
test('it checks cmd+k modal search interaction', async ({
page,
browserName,
}) => {
const [doc1Title] = await createDoc(
page,
'Doc seack ctrl k',
browserName,
1,
);
await verifyDocName(page, doc1Title);
await page.keyboard.press('Control+k');
await expect(
page.getByLabel('Search modal').getByText('search'),
).toBeVisible();
await page.keyboard.press('Escape');
const editor = page.locator('.ProseMirror');
await editor.click();
await editor.fill('Hello world');
await editor.getByText('Hello world').dblclick();
await page.keyboard.press('Control+k');
await expect(page.getByRole('textbox', { name: 'Edit URL' })).toBeVisible();
await expect(
page.getByLabel('Search modal').getByText('search'),
).toBeHidden();
});
});

View File

@@ -5,6 +5,13 @@ export const useCmdK = (callback: () => void) => {
const down = (e: KeyboardEvent) => {
if ((e.key === 'k' || e.key === 'K') && (e.metaKey || e.ctrlKey)) {
e.preventDefault();
const isProseMirrorFocused =
document.activeElement?.classList.contains('ProseMirror');
if (isProseMirrorFocused) {
return;
}
callback();
}
};