From fbe7b56054947fbe47ff48dd08f2827b5dd39420 Mon Sep 17 00:00:00 2001 From: Aditya Toshniwal Date: Tue, 17 May 2022 18:56:15 +0530 Subject: [PATCH] =?UTF-8?q?Fixed=20an=20issue=C2=A0where=20a=20popup=20for?= =?UTF-8?q?=20unsaved=20changes=20appears=20when=20clicking=C2=A0on=20the?= =?UTF-8?q?=20open=20file=20button=20for=20a=20blank=20query=20editor.=20F?= =?UTF-8?q?ixes=20#7376?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en_US/release_notes_6_10.rst | 1 + .../static/js/components/sections/MainToolBar.jsx | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/en_US/release_notes_6_10.rst b/docs/en_US/release_notes_6_10.rst index 27fd493e8..48677bbed 100644 --- a/docs/en_US/release_notes_6_10.rst +++ b/docs/en_US/release_notes_6_10.rst @@ -19,5 +19,6 @@ Bug fixes ********* | `Issue #7372 `_ - Tell Docker to always pull the latest base images when building containers. + | `Issue #7376 `_ - Fixed an issue where a popup for unsaved changes appears when clicking on the open file button for a blank query editor. | `Issue #7383 `_ - Fixed an issue where Preferences are not saved when the dialog is maximized. | `Issue #7388 `_ - Fixed an issue where an error message fills the entire window if the query is long. diff --git a/web/pgadmin/tools/sqleditor/static/js/components/sections/MainToolBar.jsx b/web/pgadmin/tools/sqleditor/static/js/components/sections/MainToolBar.jsx index bf487a2cc..19271e16b 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/sections/MainToolBar.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/sections/MainToolBar.jsx @@ -214,8 +214,8 @@ export function MainToolBar({containerRef, onFilterClick, onManageMacros}) { const openFile = useCallback(()=>{ confirmDiscard(()=>{ eventBus.fireEvent(QUERY_TOOL_EVENTS.TRIGGER_LOAD_FILE); - }); - }, []); + }, true); + }, [buttonsDisabled['save']]); const saveFile = useCallback((saveAs=false)=>{ eventBus.fireEvent(QUERY_TOOL_EVENTS.TRIGGER_SAVE_FILE, saveAs); @@ -344,7 +344,12 @@ export function MainToolBar({containerRef, onFilterClick, onManageMacros}) { let url = url_for('help.static', {'filename': queryToolCtx.params.is_query_tool ? 'query_tool.html' : 'editgrid.html'}); window.open(url, 'pgadmin_help'); }; - const confirmDiscard=(callback)=>{ + const confirmDiscard=(callback, checkSaved=false)=>{ + if(checkSaved && buttonsDisabled['save']) { + /* No need to check */ + callback(); + return; + } queryToolCtx.modal.confirm( gettext('Unsaved changes'), gettext('Are you sure you wish to discard the current changes?'),