Skip to content

Commit

Permalink
fix curation hotkeys
Browse files Browse the repository at this point in the history
  • Loading branch information
magland committed May 17, 2024
1 parent f96725c commit 4d43b78
Showing 1 changed file with 1 addition and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,9 @@ const SetupSortingCuration: FunctionComponent<PropsWithChildren<Props>> = ({chil

const {selectedUnitIds} = useSelectedUnitIds()

const handleKeyDown: KeyboardEventHandler = useCallback((e) => {
if (!e.shiftKey) return
if (selectedUnitIds.size === 0) return
let num = -1
if (e.key === '!') num = 1 // 1
else if (e.key === '@') num = 2
else if (e.key === '#') num = 3
else if (e.key === '$') num = 4
else if (e.key === '%') num = 5
else if (e.key === '^') num = 6
else if (e.key === '&') num = 7
else if (e.key === '*') num = 8
else if (e.key === '(') num = 9
else if (e.key === ')') num = 10
if (num >= 0) {
if (num - 1 < (labelChoices || []).length) {
sortingCurationDispatch({
type: 'TOGGLE_UNIT_LABEL',
label: (labelChoices || [])[num - 1],
unitId: [...selectedUnitIds]
})
}
}
}, [selectedUnitIds, labelChoices])

return (
<SortingCurationContext.Provider value={value}>
<div tabIndex={0} onKeyDown={handleKeyDown}>
<div tabIndex={0}>
{children}
</div>
</SortingCurationContext.Provider>
Expand Down

0 comments on commit 4d43b78

Please sign in to comment.