Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix(studio): run latest query from log explorer Run button (#46663)

Jordi Enric0d8f0f9e503e
diff --git a/apps/studio/pages/project/[ref]/logs/explorer/index.tsx b/apps/studio/pages/project/[ref]/logs/explorer/index.tsx
index 04eae9839a4..99bd536b04e 100644
--- a/apps/studio/pages/project/[ref]/logs/explorer/index.tsx
+++ b/apps/studio/pages/project/[ref]/logs/explorer/index.tsx
@@ -203,7 +203,11 @@ export const LogsExplorerPage: NextPageWithLayout = () => {
const handleRun = (value?: string | React.MouseEvent) => {
track('log_explorer_query_run_button_clicked', { is_saved_query: !!queryId })
- const query = typeof value === 'string' ? value || editorValue : editorValue
+ // Read the latest value straight from the editor instance rather than from
+ // `editorValue` state, which can lag behind the most recent keystroke. This
+ // keeps the Run button consistent with the Cmd+Enter keybinding.
+ const liveValue = editorRef.current?.getValue()
+ const query = typeof value === 'string' ? value || editorValue : (liveValue ?? editorValue)
const resolvedParams = buildLogQueryParams(datePickerValue, query)
setSelectedLog(null)