mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed an issue where the 'Confirm on close or refresh' setting was ignored when closing the query/ERD tool opened in the new tab. #5475
This commit is contained in:
@@ -319,6 +319,10 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
|
||||
reflectPreferences();
|
||||
});
|
||||
|
||||
pgWindow.pgAdmin.Browser.onPreferencesChange('browser', function() {
|
||||
reflectPreferences();
|
||||
});
|
||||
|
||||
/* WC docker events */
|
||||
panel?.on(window.wcDocker.EVENT.CLOSING, function() {
|
||||
window.removeEventListener('beforeunload', onBeforeUnload);
|
||||
@@ -337,7 +341,6 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
|
||||
eventBus.current.fireEvent(QUERY_TOOL_EVENTS.GOTO_LAST_SCROLL);
|
||||
}
|
||||
});
|
||||
window.addEventListener('beforeunload', onBeforeUnload);
|
||||
}, []);
|
||||
|
||||
useEffect(()=>{
|
||||
@@ -487,6 +490,19 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(()=> {
|
||||
// Add beforeunload event if "Confirm on close or refresh" option is enabled in the preferences.
|
||||
if(qtState.preferences.browser.confirm_on_refresh_close){
|
||||
window.addEventListener('beforeunload', onBeforeUnload);
|
||||
} else {
|
||||
window.removeEventListener('beforeunload', onBeforeUnload);
|
||||
}
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('beforeunload', onBeforeUnload);
|
||||
};
|
||||
}, [qtState.preferences.browser]);
|
||||
|
||||
const updateQueryToolConnection = (connectionData, isNew=false)=>{
|
||||
let currSelectedConn = _.find(qtState.connection_list, (c)=>c.is_selected);
|
||||
let currConnected = qtState.connected;
|
||||
|
||||
Reference in New Issue
Block a user