-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fixing keyboard shortcuts #27374
Fixing keyboard shortcuts #27374
Conversation
@noveens, thanks for your PR! By analyzing the history of the files in this pull request, we identified @eriksargent, @Kondou-ger and @DeepDiver1975 to be potential reviewers. |
apps/files/js/keyboardshortcuts.js
Outdated
|
||
function favorite() { | ||
var countSelected = 0; | ||
$("#fileList tr").each(function(index) { |
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 will not work. Try having more than 50 files in the list.
Then use the "select all" checkbox without scrolling down.
Then favorite.
It will miss the other entries. Need special handling.
This is because it doesn't render the next items as "tr" until you scroll down, for performance (pagination).
Might affect other shortcuts as well so I recommend to test this scenario with the other actions.
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.
On another note, the selector #fileList tr.select
would be way more direct
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.
@PVince81 ,
I'm having issues trying to get focus on the selected table row while I press the DOWN arrow key beyond the screen.
can you please give me some pointers so as to scroll the screen when the "mouseOver" tr
gets lower than the screen?
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.
Ah yes, that can be quite a struggle.
You need to get the scroll container of the list and then set its 'scrollTop' value to make it scroll down. I don't remember the details.
You can find the scroll container element by inspecting the this.$container
value of the FileList
instance.
The most difficult part here with shortcuts is that you're trying to operate directly on the DOM instead of talking with the matching FileList
instance. Currently it's not possible to get the current FileList
from the files App
object. Maybe this could be extended to make such API calls easier.
Also @PVince81 , I was thinking of implementing a controls page under personal settings, |
I think this is not needed as it is too much of a corner case. Keep it simple, sensible defaults. |
@PVince81 , They're no use unless listed somewhere. |
List them in the documentation then. Then need to find a place to put the link in the UI to access it. |
How about "general" settings under the personal tab? |
@PVince81 , Until now,
Anything else I am missing? Additions:
Thanks 😄 |
Something I'm missing now (which could be done separately) is a key to open the sidebar.
Did you solve the issue for when the list has 100 entries and only the first page is rendered ? What happens if you hit arrow up, will it render all pages first ? |
@PVince81 ,
EDIT: |
@PVince81 , views? |
Seems that after clearing the cache it works correctly on my Chromium 56. It did really weird shit. I also tested what happens if I hit shortcuts while in the rename field, it seems they are not triggered which is good.
|
@PVince81 , |
I think let it go to the parent folder, not the previously visited folder. Interestingly when I hit Backspace Chromium tells me "please use alt+left" to go to previous page. I think backspace used to be the "browser back" button shortcut. Not sure about other browsers though. |
@PVince81 , Thanks. |
@tomneedham , Thanks. |
Expected: goes to the last item 100
Given that this PR is already an improvement I'd be fine merging this first and fixing the issues separately. |
Ah, forgot to test the public link page: Public link page
you might need another approach to access to fileList instance. Other sectionsFor example "Favorites" section.
AFAIK there is no easy way to talk to the currently visible My main worry about the current file shortcut code is that it isn't really well integrated (it's very old code from back when there was only one file list view). |
apps/files/js/filelist.js
Outdated
$scrollContainer = $('body'); | ||
} | ||
|
||
if ($(".mouseOver").position().top >= this.$container.height() / 2) { |
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.
please never use absolute selectors, they are inefficient because they'd need to scan the whole page to find elements.
Use specific selectors, for example this.$el.find('.mouseOver')
apps/files/js/filelist.js
Outdated
/** | ||
* Favorite all files in the current fileList | ||
*/ | ||
favoriteAll: function() { |
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.
no, this belongs in the favorite plugin file, not the main list
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.
sure.
apps/files/js/filelist.js
Outdated
/** | ||
* Delete all files in the current fileList | ||
*/ | ||
deleteAll: function() { |
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.
I'd prefer not having a keyboard shortcut that deletes ALL files. The user must first select everything manually (ctrl+a?) and then hit delete. No direct shortcut.
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 is called only when the user clicks the select all button via mouse and presses DEL.
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 isn't any shortcut to delete all files.
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.
I see. Then you can try simulating a click on .delete-selected
instead.
apps/files/js/filelist.js
Outdated
var model = this.getModelForFile(this.files[i].name); | ||
if(!model) { | ||
// item not loaded due to pagination | ||
this._nextPage(false); |
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 only renders the next page. What if the file is two pages down ?
In general I think the file models are already available and are not dependent on pagination, so you could simply remove this "if" block.
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.
@PVince81 ,
No, the models aren't available if the element is not being displayed on the screen.
I had to introduce the check to make sure the model is made available by showing the next page.
Also, If the element is 2 pages down, it doesn't matter, the this._nextPage(false)
will be called twice (since the model for 2 page down element wouldn't also be available)
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.
Ah yes, indeed. The models won't be fully available until this big construction site is finished: #25909
will be called twice
Where does it loop ? Reading the code from top to bottom, if the second getModelForFile
still returns null
then you'll pass null
as model to the deletion trigger.
Anyway, based on my other comment this block needs to be removed anyway as it's part of the redundant deletion code.
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.
IMHO, the getModelForFile
will never return NULL after loading the next page.
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.
Maybe it's a side effect of the way you programmed this.
Since you're iterating over all files, then it is likely that before reaching the end of the page, the previous iteration it already loaded the next page, so all subsequent calls will still succeed.
My point is that the way nextPage
is implemented is that it only fetches a single next page. The way you used it seems to work somehow due to your for
loop.
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.
Yes, I fetch the nextPage if model isn't available loading the models of all the next page elements.
apps/files/js/keyboardshortcuts.js
Outdated
$("#new").addClass("active"); | ||
$(".popup.popupTop").toggle(true); | ||
$('#new li[data-type="file"]').trigger('click'); | ||
$(".new").click(); |
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.
Ideally this needs to be scoped to the currently visible file list.
You could try using the selector $('#app-content .viewcontainer:not(.hidden)'
as a prefix to only target the currently visible file list DOM elements.
apps/files/js/keyboardshortcuts.js
Outdated
function favorite() { | ||
if ($("#select_all_files").is(":checked")) { | ||
// selected all files | ||
OCA.Files.App.fileList.favoriteAll(); |
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.
OCA.Files.App.fileList
is always the fileList of "All files", not the other ones.
Maybe we should store the fileList object as a data attribute of the "viewcontainer".
Basically in the FileList constructor you add this:
this.$el.data('fileList', this);
then from outside you get the currently visible view container:
var fileList = $(#app-content .viewcontainer:not(.hidden)).data('fileList')
.
(note: might need tweaking for public link share page)
Then in all keyboard actions you can be sure that the targetted fileList object is the current one.
…s under tabs plugin
67180f9
to
c2b9d3b
Compare
@noveens there were a few comments not adressed yet. Do you intend to continue working on this ? |
Codecov Report
@@ Coverage Diff @@
## master #27374 +/- ##
=========================================
Coverage 62.15% 62.15%
Complexity 17516 17516
=========================================
Files 1045 1045
Lines 57740 57740
=========================================
Hits 35890 35890
Misses 21850 21850 Continue to review full report at Codecov.
|
@noveens any interest in bringing this to completion ? also this here would require some UX review to make sure the shortcuts are intuitive and make sense note that our focus is now on the files app in the Phoenix project instead so not sure if we should spend more effort here (effort being dev, review, qa, etc) |
I vote for close |
Description
I am trying to fix and introduce newer keyboard shortcuts.
Changes can be tested at : http://noveen.tk/core
Username : owncloud
password : 123
IMO we should try to implement a new page in settings named controls, so that the user can customise their shortcuts. (comments?)
Till now I have managed to fix various shortcuts plus introduce new shortcuts (I will keep adding them here, feel free to add shortcuts and I'll be happy to implement them)
These implementations include proper error messages plus testers for this branch are welcome !
Related Issue
#27359 #9740 #19442 #27580
Motivation and Context
Enhancement.
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist:
@PVince81 , Please guide me on this one 😄