Skip to content
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

Bugfix: Keyboard selection tab #7283

Merged
merged 2 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ We've added the possibility to navigate and select via keyboard.

https://github.com/owncloud/web/pull/7153
https://github.com/owncloud/web/issues/6029
https://github.com/owncloud/web/pull/7280
https://github.com/owncloud/web/pull/7280
https://github.com/owncloud/web/pull/7283
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,12 @@ export default defineComponent({
}),

handleShortcut(event) {
event.preventDefault()
const key = event.keyCode || event.which
const ctrl = window.navigator.platform.match('Mac') ? event.metaKey : event.ctrlKey
const shift = event.shiftKey

this.handleFileActionsShortcuts(key, ctrl)
this.handleFileSelectionShortcuts(key, shift, ctrl, event)
document.getElementById(this.keybindOnElementId).focus()
},

handleFileActionsShortcuts(key, ctrl) {
Expand Down Expand Up @@ -109,13 +107,18 @@ export default defineComponent({

handleNavigateAction(event, up = false) {
event.preventDefault()
if (!this.latestSelectedId) return
const nextId = this.getNextResourceId(up)
let nextId
if (!this.latestSelectedId) {
nextId = this.getFirstResourceId()
} else {
nextId = this.getNextResourceId(up)
}
if (nextId === -1) return
this.resetSelectionCursor()
this.resetFileSelection()
this.addFileSelection({ id: nextId })
this.scrollToResource({ id: nextId })
document.getElementById(this.keybindOnElementId).focus()
},

handleShiftClickAction(resource) {
Expand Down Expand Up @@ -215,8 +218,12 @@ export default defineComponent({
previous ? latestSelectedRow.previousSibling : latestSelectedRow.nextSibling
) as HTMLElement
if (nextRow === null) return -1
const nextResourceId = nextRow.getAttribute('data-item-id')
return nextResourceId
return nextRow.getAttribute('data-item-id')
},

getFirstResourceId() {
const firstRow = document.getElementsByClassName('oc-tbody-tr')[0]
return firstRow.getAttribute('data-item-id')
}
}
})
Expand Down