fix(sidebar): ignore toggle shortcut while typing in inputs
Skip the Cmd/Ctrl+B sidebar toggle when the event originates from a TEXTAREA, INPUT, or contentEditable element so editor shortcuts work.
This commit is contained in:
parent
49bffc04a5
commit
fb83250ff5
1 changed files with 7 additions and 0 deletions
|
|
@ -98,6 +98,13 @@ const SidebarProvider = React.forwardRef<
|
||||||
// Adds a keyboard shortcut to toggle the sidebar.
|
// Adds a keyboard shortcut to toggle the sidebar.
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const handleKeyDown = (event: KeyboardEvent) => {
|
const handleKeyDown = (event: KeyboardEvent) => {
|
||||||
|
const target = event.target;
|
||||||
|
if (
|
||||||
|
target instanceof HTMLElement &&
|
||||||
|
(target.tagName === "TEXTAREA" || target.tagName === "INPUT" || target.isContentEditable)
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
|
if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
toggleSidebar();
|
toggleSidebar();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue