-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basic keyboard shortcuts #567
Conversation
test/check-application
Outdated
b.wait_text(".breadcrumb-button:nth-of-type(5)", "anotherdir") | ||
|
||
# Go back in history twice | ||
# b.key("ArrowLeft", repeat=2, modifiers=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jelly do you have any idea what might be happening here? the b.key(...)
doesn't seem to work when running this test in chromium but everything works fine in firefox
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The biggest thing which is missing (and should be added after discussion) is a way to view the keybindings. We should have a dropdownitem in the main kebab + modal for that.
- Moving up / out of a directory key bindings seems a little bit obscure to me.
- F2 for rename, this feels so random? Which applications have this as default?
yes, I will add this when we are more settled with shortcuts
both dolphin and nautilus |
src/files-card-body.jsx
Outdated
case "N": | ||
if (!e.ctrlKey && !e.altKey) { | ||
Dialogs.show( | ||
<CreateDirectoryModal currentPath={currentPath} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooops, looks like this slipped my mind!
Turns out |
ac26b32
to
8893f60
Compare
We have mockups for that in the menu and an issue for that already @ #451
We have an issue for this already, where I suggested control-shift-L, which aligns with how browsers and file managers use control-L, but adds in the shift as to not stomp on browser behavior: #450 |
BTW: Mockup and explanation for keyboard shortcuts reference modal is now @ #451 (comment) |
8893f60
to
8ee3c5a
Compare
I've pushed up my changes to restyle the keyboard shortcuts. Now, it:
|
It's also the way you rename in Explorer, in Windows. Meanwhile, for renaming, macOS uses... enter. (Yes, I'm not kidding.) Everywhere else, including browsers on a focused area or widget, enter activates. But in Finder, it's to rename. F2 makes more sense than enter, and it's a keyboard shortcut most people are already familiar with if they use keyboard shortcuts in file managers. |
c3d4aa3
to
1745428
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one big issue, when I browse to a directory where I get a permission denied or a non-existant directory then the keybindings no longer work as the eventhandlers are only added on "valid folders".
2c25a52
to
adceb56
Compare
src/header.tsx
Outdated
const onSelect = (_ev?: React.MouseEvent, itemId?: string | number) => { | ||
if (itemId === "hidden-toggle") { | ||
setShowHidden(prevShowHidden => { | ||
localStorage.setItem("files:showHiddenFiles", !showHidden ? "true" : "false"); | ||
return !prevShowHidden; | ||
}); | ||
} else if (itemId === "shortcuts-help") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dw it is tested :)
eca07b3
to
802c7dd
Compare
0b2424a
to
92b7601
Compare
src/header.tsx
Outdated
const onSelect = (_ev?: React.MouseEvent, itemId?: string | number) => { | ||
if (itemId === "hidden-toggle") { | ||
setShowHidden(prevShowHidden => { | ||
localStorage.setItem("files:showHiddenFiles", !showHidden ? "true" : "false"); | ||
return !prevShowHidden; | ||
}); | ||
} else if (itemId === "shortcuts-help") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird hmmm
Agreed; the keyboard shortcuts modal is supposed to go in the main menu, not the view menu. |
92b7601
to
3803209
Compare
3803209
to
575e42a
Compare
CI red, fixing in #727 |
@garrett what was the idea/ design here? |
It should go into the menu, which is supposed to be in the place where the menu should be — and that was never in the sidebar. The sidebar never had a menu in any of the mockups at any point in time. The fact that the sidebar has a menu in main is a huge UX bug. (I've pointed this out several times during development, but we haven't moved it as I had an in progress mockup for some time now and haven't had the opportunity to address it properly yet.) The menu was always supposed to be either global and/or in the toolbar. The current mockups — which I haven't had time to finish yet — have the menu in the toolbar. The current state of the sidebarless redesign with merged menus looks like this: But it's unfinished, so it's subject to change. And it will change. But the menu position is probably the most solid of this mockup at this point, and the menu items are probably pretty close too. I basically made a compromise after looking at other file management apps and seeing they have a menu like this too, on Windows, macOS, and KDE. GNOME's is different, as they don't act upon the selection (and rely on a context menu only), but everything else does. Other designs for it have it come after the selected items, which is more proper in the idea of a flow, but non-GNOME file managers, word processors, and all kinds of other apps actually do sometimes change their menus and toolbars (including toolbar icons) based on selection of what comes after it in the UI, so it's OK enough for us to do this too. And it's probably what everyone other than people using GNOME would expect. I think we'd want to also adjust the context menu to be similar too. For now, I think the correct solution is to have the opposite of a "follow-up" and make a separate PR that moves the menu from the sidebar to the toolbar (to the right of the upload button) as a first step. Summary: Move the menu from the sidebar to the toolbar first, then make sure the keyboard shortcuts are in the menu at the bottom. |
relevant comment: cockpit-project#567 (comment)
relevant comment: cockpit-project#567 (comment)
relevant comment: cockpit-project#567 (comment)
relevant comment: cockpit-project#567 (comment)
575e42a
to
527580d
Compare
relevant comment: cockpit-project#567 (comment)
relevant comment: cockpit-project#567 (comment)
relevant comment: cockpit-project#567 (comment)
relevant comment: #567 (comment)
8d027e5
to
84ce5a0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, some minor fixes / suggestions and then I think it's good to land
fixes: cockpit-project#451 For now this adds following keybindings: - `alt + arrow up`: go up one directory - `alt + arrow down`: activate selected item, enter directory - `Enter`: activate selected item, enter directory - `ctrl + shift + L`: focus files breadcrumbs to manually edit it - `F2`: rename selected file - `shift + N`: create new directory - `ctrl + c`: copy file/directory - `ctrl + v`: paste file/directory - `ctrl + a`: select all files Alt + arrow left/right is already supported by cockpit files browser history.
542a8d0
to
99bc362
Compare
return () => { | ||
document.removeEventListener("keydown", onKeyboardNav); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These 2 added lines are not executed by any test.
title={_("Keyboard shortcuts")} | ||
variant={ModalVariant.large} | ||
className="shortcuts-dialog" | ||
onClose={() => dialogResult.resolve()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added line is not executed by any test.
const selectedIdx = sortedFiles?.findIndex(file => file.name === firstSelectedName); | ||
const newIdx = selectedIdx < sortedFiles.length - 1 | ||
? selectedIdx + 1 | ||
: 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added line is not executed by any test.
const selectedIdx = sortedFiles?.findIndex(file => file.name === firstSelectedName); | ||
const newIdx = selectedIdx > 0 | ||
? selectedIdx - 1 | ||
: sortedFiles.length - 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added line is not executed by any test.
"-R", | ||
...clipboard, | ||
path | ||
]).catch(err => addAlert(err.message, AlertVariant.danger, `${new Date().getTime()}`)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added line is not executed by any test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small comments and one follow up but let's not let this block this for much longer.
return () => { | ||
document.removeEventListener("keydown", onKeyboardNav); | ||
}; | ||
}, []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dependency array can go
@@ -1174,6 +1177,20 @@ class TestFiles(testlib.MachineCase): | |||
b.wait_not_present(".pf-v5-c-modal-box") | |||
b.wait_visible("[data-item='renamed-foo.txt']") | |||
|
|||
# Rename file using keyboard shortcut | |||
b.click("[data-item='newfile']") | |||
b.key("\uE032") # F2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm any reason "F2" doesn't work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could work if I add it here in testlib: https://github.com/cockpit-project/cockpit/blob/dc2085e95137ced40e03c94b8b2ebcf090a8acea/test/common/testlib.py#L103
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems worth it, let's do it :) But don't block merging on it.
@@ -814,6 +814,9 @@ class TestFiles(testlib.MachineCase): | |||
b.mouse("[data-item='delete2']", "click", ctrlKey=True) | |||
b.wait_visible("[data-item='delete1'].row-selected") | |||
b.wait_visible("[data-item='delete2'].row-selected") | |||
b.focus("#files-card-parent") | |||
# For strange reasons ctrlKey remains pressed after the b.mouse() above (spotted in firefox) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we keep seeing this in the keyboard event, sounds like something we should investigate in Bidi
fixes: #451
For now this adds following keybindings:
alt + arrow up
: go up one directoryalt + arrow down
: activate selected item, enter directoryEnter
: activate selected item, enter directoryctrl + shift + L
: focus files breadcrumbs to manually edit itF2
: rename selected fileshift + N
: create new directoryctrl + c
: copy file/directoryctrl + v
: paste file/directoryctrl + a
: select all filesAlt + arrow left/right is already supported by cockpit files browser
history.
Files: basic keyboard shortcuts