mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
fix: prevent blocking history navigation shortcut
This commit is contained in:
parent
e70f31567b
commit
e1495fef45
1 changed files with 14 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ import { GetCreatedMethod, MethodCreator } from 'driver/connect'
|
|||
import { platform } from 'platforms'
|
||||
import { Config } from 'utils/config/helper'
|
||||
import * as DOMHelper from 'utils/DOMHelper'
|
||||
import { OperatingSystems, os } from 'utils/general'
|
||||
import { VisibleNodes, VisibleNodesGenerator } from 'utils/VisibleNodesGenerator'
|
||||
|
||||
export type Props = {
|
||||
|
|
@ -132,6 +133,10 @@ export const handleKeyDown: BoundMethodCreator<[React.KeyboardEvent]> = dispatch
|
|||
break
|
||||
|
||||
case 'ArrowLeft':
|
||||
if (wouldBlockHistoryNavigation(event)) {
|
||||
muteEvent = false
|
||||
break
|
||||
}
|
||||
if (expandedNodes.has(focusedNode.path)) {
|
||||
dispatch.call(toggleNodeExpansion, focusedNode, { recursive: event.altKey })
|
||||
} else {
|
||||
|
|
@ -145,6 +150,10 @@ export const handleKeyDown: BoundMethodCreator<[React.KeyboardEvent]> = dispatch
|
|||
|
||||
// consider the two keys as 'confirm' key
|
||||
case 'ArrowRight':
|
||||
if (wouldBlockHistoryNavigation(event)) {
|
||||
muteEvent = false
|
||||
break
|
||||
}
|
||||
// expand node or focus on first content node or redirect to file page
|
||||
if (focusedNode.type === 'tree') {
|
||||
if (expandedNodes.has(focusedNode.path)) {
|
||||
|
|
@ -305,3 +314,8 @@ export const expandTo: BoundMethodCreator<[string[]]> = dispatch => async curren
|
|||
visibleNodesGenerator.focusNode(nodeExpandedTo)
|
||||
}
|
||||
}
|
||||
|
||||
function wouldBlockHistoryNavigation(event: React.KeyboardEvent) {
|
||||
// Alt + left/right is usually history navigation shortcut on OS other than macOS
|
||||
return os !== OperatingSystems.macOS && event.altKey
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue