File tree Expand file tree Collapse file tree
apps/sim/app/workspace/[workspaceId] Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -298,7 +298,8 @@ export function KnowledgeBase({
298298 // doesn't refetch on every keystroke. Changing the search resets pagination.
299299 const handleSearchChange = useCallback (
300300 ( newQuery : string ) => {
301- const next = newQuery . length > 0 ? newQuery : null
301+ const trimmed = newQuery . trim ( )
302+ const next = trimmed . length > 0 ? trimmed : null
302303 setDocumentFilters (
303304 { q : next } ,
304305 next === null ? undefined : { limitUrlUpdates : debounce ( 300 ) }
Original file line number Diff line number Diff line change @@ -422,10 +422,24 @@ export default function Logs() {
422422 const handleCloseSidebar = useCallback ( ( ) => {
423423 dispatch ( { type : 'CLOSE_SIDEBAR' } )
424424 activeLogTabRef . current = 'overview'
425- // Strip `tab` from the URL (back to the default) so reopening another log
426- // starts on the overview tab instead of inheriting the closed log's tab.
427- setLogDetailsTab ( null )
428- } , [ setLogDetailsTab ] )
425+ } , [ ] )
426+
427+ /**
428+ * Strip the `tab` param whenever the detail panel transitions from open to
429+ * closed — by the X button, toggling the same row, or the keyboard — so
430+ * reopening another log starts on overview rather than inheriting the closed
431+ * log's tab. Guarded on a prior-open ref so an initial deep-linked `?tab=` is
432+ * preserved (the panel isn't open yet on first mount).
433+ */
434+ const wasSidebarOpenRef = useRef ( false )
435+ useEffect ( ( ) => {
436+ if ( isSidebarOpen ) {
437+ wasSidebarOpenRef . current = true
438+ } else if ( wasSidebarOpenRef . current ) {
439+ wasSidebarOpenRef . current = false
440+ setLogDetailsTab ( null )
441+ }
442+ } , [ isSidebarOpen , setLogDetailsTab ] )
429443
430444 const handleActiveTabChange = useCallback ( ( tab : string ) => {
431445 activeLogTabRef . current = tab
You can’t perform that action at this time.
0 commit comments