Skip to content

Commit 0e798e1

Browse files
authored
Merge pull request #104 from moda20/Improvement/UI-UX-improvements
[DEV-IMP] A small QoL improvement for hotkeys and cmdk focus
2 parents 812dda0 + 9bcd339 commit 0e798e1

2 files changed

Lines changed: 21 additions & 11 deletions

File tree

src/components/custom/SearchBar.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ export default function SearchBar({ trigger }: SearchBarProps) {
151151
batchProcessIds?: number[],
152152
) => {
153153
await takeAction(row, action, data, batchProcessIds)
154+
if (isDialogOpen) {
155+
inputRef.current?.focus()
156+
}
154157
switch (action) {
155158
case jobActions.UPDATE:
156159
case jobActions.UNSCHEDULE:

src/components/custom/general/DropdownItemExtended.tsx

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,24 @@ const DropdownMenuItemExtended = React.forwardRef<
1414
>(({ className, inset, keyBinding, onAction, ...props }, ref) => {
1515
const newRef = useRef<HTMLDivElement>(null)
1616
useImperativeHandle(ref, () => newRef.current as HTMLInputElement)
17-
useHotkeys(keyBinding ?? "", ev => {
18-
if (props.disabled) {
19-
return
20-
}
21-
if (onAction) {
22-
onAction(ev)
23-
}
24-
if (newRef.current) {
25-
newRef.current.dispatchEvent(new MouseEvent("click", { bubbles: true }))
26-
}
27-
})
17+
useHotkeys(
18+
keyBinding ?? "",
19+
ev => {
20+
if (props.disabled) {
21+
return
22+
}
23+
if (onAction) {
24+
onAction(ev)
25+
}
26+
if (newRef.current) {
27+
newRef.current.dispatchEvent(new MouseEvent("click", { bubbles: true }))
28+
}
29+
},
30+
{
31+
enableOnFormTags: true,
32+
enableOnContentEditable: true,
33+
},
34+
)
2835
return <DropdownMenuItem ref={newRef} {...props} />
2936
})
3037
DropdownMenuItemExtended.displayName = DropdownMenuItem.displayName

0 commit comments

Comments
 (0)