mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-10-31 00:12:39 +00:00
fix: make Backspace delete the selection in Files, as in Mail, and keep Alt+Up for going up
This commit is contained in:
@@ -354,4 +354,26 @@ describe('FileBrowser', () => {
|
||||
fireEvent.keyDown(input, { key: 'Escape' });
|
||||
expect(screen.queryByRole('dialog', { name: 'rename_title' })).toBeNull();
|
||||
});
|
||||
|
||||
it("deletes the selection with Backspace, as Mail does, and goes up a folder only with Alt+Up", () => {
|
||||
const onDelete = vi.fn(async () => {});
|
||||
const onNavigate = vi.fn();
|
||||
renderBrowser({ props: { currentPath: '/Documents', selectedResources: new Set(['notes.txt']), onDelete, onNavigate } });
|
||||
fireEvent.keyDown(window, { key: 'Backspace' });
|
||||
expect(onDelete).toHaveBeenCalledWith('notes.txt');
|
||||
expect(onNavigate).not.toHaveBeenCalled();
|
||||
|
||||
fireEvent.keyDown(window, { key: 'ArrowUp', altKey: true });
|
||||
expect(onNavigate).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("keeps the selection when Escape closes an item's menu", () => {
|
||||
const onClearSelection = vi.fn();
|
||||
renderBrowser({ props: { selectedResources: new Set(['notes.txt', 'Documents']), onClearSelection } });
|
||||
fireEvent.contextMenu(within(list()).getByText('notes.txt'));
|
||||
expect(screen.getByRole('menu')).toBeInTheDocument();
|
||||
fireEvent.keyDown(document.activeElement ?? window, { key: 'Escape' });
|
||||
expect(screen.queryByRole('menu')).toBeNull();
|
||||
expect(onClearSelection).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -704,7 +704,8 @@ export function FileBrowser({
|
||||
else if (selected.length > 0) onClearSelection();
|
||||
return;
|
||||
}
|
||||
if (e.key === "Delete" && selected.length > 0) {
|
||||
// Backspace deletes too, as in Mail (⌘⌫ on a Mac); Alt+↑ goes up.
|
||||
if ((e.key === "Delete" || e.key === "Backspace") && selected.length > 0) {
|
||||
e.preventDefault();
|
||||
deleteNames(selected);
|
||||
return;
|
||||
@@ -724,7 +725,7 @@ export function FileBrowser({
|
||||
onToggleSelect(focusedName);
|
||||
return;
|
||||
}
|
||||
if ((e.key === "Backspace" || (e.altKey && e.key === "ArrowUp")) && currentPath !== "/") {
|
||||
if (e.altKey && e.key === "ArrowUp" && currentPath !== "/") {
|
||||
e.preventDefault();
|
||||
navigateUp();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user