fix(ui): Prevent Command from triggering while a editable field has focus (#11254)
Resolves CMRC-909
This commit is contained in:
committed by
GitHub
parent
f07af7b93c
commit
3cf4307296
@@ -5,6 +5,7 @@ import * as React from "react"
|
||||
|
||||
import { Kbd } from "@/components/kbd"
|
||||
import { clx } from "@/utils/clx"
|
||||
import { isInputElement } from "@/utils/is-input-element"
|
||||
|
||||
interface CommandBarProps extends React.PropsWithChildren {
|
||||
open?: boolean
|
||||
@@ -166,6 +167,10 @@ const Command = React.forwardRef<HTMLButtonElement, CommandProps>(
|
||||
) => {
|
||||
React.useEffect(() => {
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (isInputElement(document.activeElement)) {
|
||||
return
|
||||
}
|
||||
|
||||
if (event.key.toLowerCase() === shortcut.toLowerCase()) {
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
|
||||
Reference in New Issue
Block a user