fix/search bar in codeeditor (#7841)

This commit is contained in:
shubh-bruno
2026-04-27 11:25:26 +05:30
committed by GitHub
parent c91e5fd9c7
commit 9361393a49
2 changed files with 11 additions and 14 deletions

View File

@@ -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

View File

@@ -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);