diff --git a/packages/bruno-app/src/components/Sidebar/index.js b/packages/bruno-app/src/components/Sidebar/index.js index 050d1a456..6fb848729 100644 --- a/packages/bruno-app/src/components/Sidebar/index.js +++ b/packages/bruno-app/src/components/Sidebar/index.js @@ -4,9 +4,10 @@ import StyledWrapper from './StyledWrapper'; import { useState, useEffect, useRef } from 'react'; import { useSelector, useDispatch } from 'react-redux'; -import { updateLeftSidebarWidth, updateIsDragging } from 'providers/ReduxStore/slices/app'; +import { updateLeftSidebarWidth, updateIsDragging, toggleSidebarSearch } from 'providers/ReduxStore/slices/app'; import CollectionsSection from './Sections/CollectionsSection/index'; import ApiSpecsSection from './Sections/ApiSpecsSection/index'; +import useKeybinding from 'hooks/useKeybinding'; const MIN_LEFT_SIDEBAR_WIDTH = 220; const MAX_LEFT_SIDEBAR_WIDTH = 600; @@ -31,6 +32,14 @@ const Sidebar = () => { const dispatch = useDispatch(); const [dragging, setDragging] = useState(false); + // Sidebar search + useKeybinding('sidebarSearch', (e) => { + const target = e?.target || document.activeElement; + if (target?.closest?.('.CodeMirror')) return; // let editor's native `Find` handle it + dispatch(toggleSidebarSearch()); + return false; + }); + const currentWidth = sidebarCollapsed ? 0 : asideWidth; // Clamp helper keeps width in allowed range diff --git a/packages/bruno-app/src/providers/Hotkeys/index.js b/packages/bruno-app/src/providers/Hotkeys/index.js index 952cbc545..18cb152fa 100644 --- a/packages/bruno-app/src/providers/Hotkeys/index.js +++ b/packages/bruno-app/src/providers/Hotkeys/index.js @@ -10,7 +10,7 @@ import each from 'lodash/each'; import { findCollectionByUid, findItemInCollection, flattenItems, isItemARequest, hasRequestChanges, findEnvironmentInCollection } from 'utils/collections'; import { addTab, focusTab, reorderTabs } from 'providers/ReduxStore/slices/tabs'; import { saveMultipleRequests, saveMultipleCollections, saveMultipleFolders, saveEnvironment, reopenClosedTab } from 'providers/ReduxStore/slices/collections/actions'; -import { toggleSidebarCollapse, toggleSidebarSearch, savePreferences } from 'providers/ReduxStore/slices/app'; +import { toggleSidebarCollapse, savePreferences } from 'providers/ReduxStore/slices/app'; import { openDevtoolsAndSwitchToTerminal } from 'utils/terminal'; import { getKeyBindingsForActionAllOS } from './keyMappings'; @@ -289,18 +289,6 @@ export const HotkeysProvider = (props) => { }; }, [dispatch, userKeyBindings, keybindingsEnabled]); - // Sidebar search - useEffect(() => { - bindAction('sidebarSearch', (e) => { - dispatch(toggleSidebarSearch()); - return false; - }); - - return () => { - unbindAction('sidebarSearch'); - }; - }, [dispatch, userKeyBindings, keybindingsEnabled]); - // Open terminal — context-aware: // focusedSidebarPath: null = no sidebar focus, '' = request focused (no-op), '/path' = folder/collection const focusedSidebarPath = useSelector((state) => state.app.focusedSidebarPath);