Skip to content

Commit b3b6db0

Browse files
Independent Panel: focus search on shortcuts even when collapsed\n\n- Intercept Ctrl/Cmd+F and '/' globally; expand sidebar if collapsed, then focus + select search input\n- Keep '/' disabled while typing in inputs/textareas/contenteditable\n\nWhy: Requested behavior change to allow quick search access even when the sidebar is collapsed, replacing earlier non-hijack behavior.
1 parent 8d60997 commit b3b6db0

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

src/pages/IndependentPanel/App.jsx

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -136,33 +136,37 @@ function App() {
136136

137137
// Keyboard shortcuts: Ctrl/Cmd+F and '/' to focus search
138138
useEffect(() => {
139+
const focusSearch = () => {
140+
if (collapsed) {
141+
setCollapsed(false)
142+
setUserConfig({ independentPanelCollapsed: false })
143+
setTimeout(() => {
144+
if (searchInputRef.current) {
145+
searchInputRef.current.focus()
146+
searchInputRef.current.select()
147+
}
148+
}, 0)
149+
} else if (searchInputRef.current) {
150+
searchInputRef.current.focus()
151+
searchInputRef.current.select()
152+
}
153+
}
139154
const onKeyDown = (e) => {
140155
const target = e.target
141156
const isTypingField =
142157
target &&
143158
(target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable)
144159

145-
// Only override browser find when sidebar is expanded and search is visible
146-
if (
147-
!collapsed &&
148-
(e.ctrlKey || e.metaKey) &&
149-
!e.altKey &&
150-
!e.shiftKey &&
151-
e.key.toLowerCase() === 'f'
152-
) {
153-
if (searchInputRef.current) {
154-
e.preventDefault()
155-
searchInputRef.current.focus()
156-
searchInputRef.current.select()
157-
}
160+
// Always override browser find to route to panel search
161+
if ((e.ctrlKey || e.metaKey) && !e.altKey && !e.shiftKey && e.key.toLowerCase() === 'f') {
162+
e.preventDefault()
163+
focusSearch()
158164
return
159165
}
160166

161-
if (!collapsed && !isTypingField && !e.ctrlKey && !e.metaKey && !e.altKey && e.key === '/') {
162-
if (searchInputRef.current) {
163-
e.preventDefault()
164-
searchInputRef.current.focus()
165-
}
167+
if (!isTypingField && !e.ctrlKey && !e.metaKey && !e.altKey && e.key === '/') {
168+
e.preventDefault()
169+
focusSearch()
166170
}
167171
}
168172
window.addEventListener('keydown', onKeyDown)

0 commit comments

Comments
 (0)