mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-10-31 00:12:39 +00:00
fix: open a new event with n without typing the n into its title
This commit is contained in:
@@ -222,6 +222,15 @@ describe('CalendarApp unsaved editor changes', () => {
|
||||
await waitFor(() => expect(screen.queryByPlaceholderText('form.title')).toBeNull());
|
||||
});
|
||||
|
||||
it('opens the editor on n without typing the n into its title', async () => {
|
||||
renderApp();
|
||||
const press = new KeyboardEvent('keydown', { key: 'n', code: 'KeyN', bubbles: true, cancelable: true });
|
||||
document.body.dispatchEvent(press);
|
||||
// A key whose keydown is not cancelled goes on to type its character
|
||||
expect(press.defaultPrevented).toBe(true);
|
||||
expect(await screen.findByPlaceholderText('form.title')).toHaveValue('');
|
||||
});
|
||||
|
||||
it('closes an untouched editor without asking', () => {
|
||||
renderApp();
|
||||
fireEvent.keyDown(document.body, { key: 'n', code: 'KeyN' });
|
||||
|
||||
@@ -1552,7 +1552,8 @@ export function CalendarApp({ linkSegments: routeSegments }: CalendarAppProps =
|
||||
case "day": setViewMode("day"); break;
|
||||
case "agenda": setViewMode("agenda"); break;
|
||||
case "tasks": if (enableCalendarTasks) setViewMode("tasks"); break;
|
||||
case "new": openCreateForView(); break;
|
||||
// Kept from typing itself into the title field the editor focuses.
|
||||
case "new": e.preventDefault(); openCreateForView(); break;
|
||||
}
|
||||
};
|
||||
window.addEventListener("keydown", handleKey);
|
||||
|
||||
Reference in New Issue
Block a user