diff --git a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx index 3a3920a82..eb80b4574 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx @@ -283,6 +283,12 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN eventBus.current.fireEvent(QUERY_TOOL_EVENTS.HANDLE_API_ERROR, err); setQtStatePartial({ editor_disabled: true }); }); + } else if (qtState.params.sql_id) { + let sqlValue = localStorage.getItem(qtState.params.sql_id); + localStorage.removeItem(qtState.params.sql_id); + if (sqlValue) { + eventBus.current.fireEvent(QUERY_TOOL_EVENTS.EDITOR_SET_SQL, sqlValue); + } } else if (qtState.params.toolDataId) { populateEditorData(); } else {