Skip to content

Commit

Permalink
fix(ui): disable hotkeys on modals (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
bouassaba authored Sep 27, 2024
1 parent db439ea commit f9113a1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ui/src/client/api/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ export type List = {
export type UserPermission = {
id: string
user: User
permission: string
permission: PermissionType
}

export type GroupPermission = {
id: string
group: Group
permission: string
permission: PermissionType
}

export type Query = {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/client/api/permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const VIEWER_PERMISSION = 'viewer'
export const EDITOR_PERMISSION = 'editor'
export const OWNER_PERMISSION = 'owner'

export type PermissionType = 'viewer' | 'editor' | 'owner'
export type PermissionType = 'viewer' | 'editor' | 'owner' | 'none'

export function gtViewerPermission(permission: string): boolean {
return (
Expand Down
14 changes: 13 additions & 1 deletion ui/src/components/file/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ const FileList = ({ list, scale }: FileListProps) => {
(state) => state.ui.files.isSelectionMode,
)
const selection = useAppSelector((state) => state.ui.files.selection)
const isModalOpen = useAppSelector(
(state) =>
state.ui.files.isCopyModalOpen ||
state.ui.files.isMoveModalOpen ||
state.ui.files.isDeleteModalOpen ||
state.ui.files.isCreateModalOpen ||
state.ui.files.isShareModalOpen ||
state.ui.files.isRenameModalOpen,
)
const [activeId, setActiveId] = useState<string | null>(null)
const [isMenuOpen, setIsMenuOpen] = useState(false)
const [menuPosition, setMenuPosition] = useState<FileMenuPosition>()
Expand Down Expand Up @@ -136,6 +145,9 @@ const FileList = ({ list, scale }: FileListProps) => {

const handleKeyDown = useCallback(
(keyName: string, event: KeyboardEvent) => {
if (isModalOpen) {
return
}
event.preventDefault()
if (
(keyName === 'command+a' && isMacOS()) ||
Expand Down Expand Up @@ -172,7 +184,7 @@ const FileList = ({ list, scale }: FileListProps) => {
}
}
},
[selection],
[selection, isModalOpen],
)

return (
Expand Down

0 comments on commit f9113a1

Please sign in to comment.