mirror of https://github.com/laurent22/joplin.git
Desktop: Fixes #10685: Fix shift-delete asks to permanently delete the current note, rather than cut text, when the editor is selected. (#10687)
parent
a3e04103de
commit
2fd6a3a2fa
|
@ -104,10 +104,17 @@ const useOnKeyDown = (
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noteIds.length && (key === 'Delete' || (key === 'Backspace' && event.metaKey))) {
|
if (noteIds.length) {
|
||||||
event.preventDefault();
|
if (key === 'Delete' && event.shiftKey) {
|
||||||
if (CommandService.instance().isEnabled('deleteNote')) {
|
event.preventDefault();
|
||||||
void CommandService.instance().execute('deleteNote', noteIds);
|
if (CommandService.instance().isEnabled('permanentlyDeleteNote')) {
|
||||||
|
void CommandService.instance().execute('permanentlyDeleteNote', noteIds);
|
||||||
|
}
|
||||||
|
} else if (key === 'Delete' || (key === 'Backspace' && event.metaKey)) {
|
||||||
|
event.preventDefault();
|
||||||
|
if (CommandService.instance().isEnabled('deleteNote')) {
|
||||||
|
void CommandService.instance().execute('deleteNote', noteIds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import { test, expect } from './util/test';
|
import { test, expect } from './util/test';
|
||||||
import MainScreen from './models/MainScreen';
|
import MainScreen from './models/MainScreen';
|
||||||
|
import activateMainMenuItem from './util/activateMainMenuItem';
|
||||||
|
import setMessageBoxResponse from './util/setMessageBoxResponse';
|
||||||
|
|
||||||
test.describe('noteList', () => {
|
test.describe('noteList', () => {
|
||||||
test('should be possible to edit notes in a different notebook when searching', async ({ mainWindow }) => {
|
test('should be possible to edit notes in a different notebook when searching', async ({ mainWindow }) => {
|
||||||
|
@ -35,4 +37,42 @@ test.describe('noteList', () => {
|
||||||
// Updating the title should force the sidebar to update sooner
|
// Updating the title should force the sidebar to update sooner
|
||||||
await expect(editor.noteTitleInput).toHaveValue('note-1');
|
await expect(editor.noteTitleInput).toHaveValue('note-1');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('shift-delete should ask to permanently delete notes, but only when the note list is focused', async ({ electronApp, mainWindow }) => {
|
||||||
|
const mainScreen = new MainScreen(mainWindow);
|
||||||
|
const sidebar = mainScreen.sidebar;
|
||||||
|
|
||||||
|
const folderBHeader = await sidebar.createNewFolder('Folder B');
|
||||||
|
const folderAHeader = await sidebar.createNewFolder('Folder A');
|
||||||
|
await expect(folderAHeader).toBeVisible();
|
||||||
|
|
||||||
|
await mainScreen.createNewNote('test note 1');
|
||||||
|
await mainScreen.createNewNote('test note 2');
|
||||||
|
|
||||||
|
await activateMainMenuItem(electronApp, 'Note list', 'Focus');
|
||||||
|
await expect(mainScreen.noteListContainer.getByText('test note 1')).toBeVisible();
|
||||||
|
|
||||||
|
await setMessageBoxResponse(electronApp, /^Delete/i);
|
||||||
|
|
||||||
|
const pressShiftDelete = async () => {
|
||||||
|
await mainWindow.keyboard.press('Shift');
|
||||||
|
await mainWindow.keyboard.press('Delete');
|
||||||
|
await mainWindow.keyboard.up('Delete');
|
||||||
|
await mainWindow.keyboard.up('Shift');
|
||||||
|
};
|
||||||
|
await pressShiftDelete();
|
||||||
|
|
||||||
|
await folderBHeader.click();
|
||||||
|
await folderAHeader.click();
|
||||||
|
await expect(mainScreen.noteListContainer.getByText('test note 2')).not.toBeVisible();
|
||||||
|
|
||||||
|
// Should not delete when the editor is focused
|
||||||
|
await mainScreen.noteEditor.focusCodeMirrorEditor();
|
||||||
|
await mainWindow.keyboard.type('test');
|
||||||
|
await pressShiftDelete();
|
||||||
|
|
||||||
|
await folderBHeader.click();
|
||||||
|
await folderAHeader.click();
|
||||||
|
await expect(mainScreen.noteListContainer.getByText('test note 1')).toBeVisible();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -108,7 +108,6 @@ const defaultKeymapItems = {
|
||||||
{ accelerator: 'Ctrl+Alt+1', command: 'switchProfile1' },
|
{ accelerator: 'Ctrl+Alt+1', command: 'switchProfile1' },
|
||||||
{ accelerator: 'Ctrl+Alt+2', command: 'switchProfile2' },
|
{ accelerator: 'Ctrl+Alt+2', command: 'switchProfile2' },
|
||||||
{ accelerator: 'Ctrl+Alt+3', command: 'switchProfile3' },
|
{ accelerator: 'Ctrl+Alt+3', command: 'switchProfile3' },
|
||||||
{ accelerator: 'Shift+Delete', command: 'permanentlyDeleteNote' },
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue