diff --git a/apps/studio/pages/project/[ref]/logs/explorer/index.tsx b/apps/studio/pages/project/[ref]/logs/explorer/index.tsx index c29beb0b7b3..38c94f560d7 100644 --- a/apps/studio/pages/project/[ref]/logs/explorer/index.tsx +++ b/apps/studio/pages/project/[ref]/logs/explorer/index.tsx @@ -72,7 +72,7 @@ export const LogsExplorerPage: NextPageWithLayout = () => { const editorRef = useRef() const [editorId] = useState(uuidv4()) - const { timestampStart, timestampEnd, setTimeRange } = useLogsUrlState() + const { search, setSearch, timestampStart, timestampEnd, setTimeRange } = useLogsUrlState() const defaultHelper = useMemo(() => getDefaultHelper(EXPLORER_DATEPICKER_HELPERS), []) const initialDatePickerValue = useMemo(() => { if (timestampStart && timestampEnd) { @@ -217,15 +217,7 @@ export const LogsExplorerPage: NextPageWithLayout = () => { } else { setTimeRange('', '') } - const queryParams: Record = { ...router.query, q: query } - if (datePickerValue.isHelper) { - delete queryParams.its - delete queryParams.ite - } - router.push({ - pathname: router.pathname, - query: queryParams, - }) + setSearch(query) addRecentLogSqlSnippet({ sql: query }) } @@ -326,10 +318,13 @@ export const LogsExplorerPage: NextPageWithLayout = () => { } useEffect(() => { - if (q) { + if (search) { + setEditorValue(search) + } else if (q) { setEditorValue(q) + setSearch(q) } - }, [q]) + }, [q, search, setSearch]) useEffect(() => { // prevents overwriting when the user selects a helper.