@@ -843,28 +843,28 @@ export const openTabFromCurrent = (
843843 } ;
844844} ;
845845
846+ async function confirmClosingTabs ( ) {
847+ return await showConfirmation ( {
848+ title : 'Are you sure you want to close the tab?' ,
849+ description :
850+ 'The content of this tab has been modified. You will lose your changes if you close it.' ,
851+ buttonText : 'Close tab' ,
852+ variant : 'danger' ,
853+ 'data-testid' : 'confirm-tab-close' ,
854+ } ) ;
855+ }
856+
846857type CloseTabAction = { type : WorkspacesActions . CloseTab ; atIndex : number } ;
847858
848859export const closeTab = (
849860 atIndex : number
850861) : WorkspacesThunkAction < Promise < void > , CloseTabAction > => {
851862 return async ( dispatch , getState ) => {
852863 const tab = getState ( ) . tabs [ atIndex ] ;
853- if ( ! canCloseTab ( tab ) ) {
854- const confirmClose = await showConfirmation ( {
855- title : 'Are you sure you want to close the tab?' ,
856- description :
857- 'The content of this tab has been modified. You will lose your changes if you close it.' ,
858- buttonText : 'Close tab' ,
859- variant : 'danger' ,
860- 'data-testid' : 'confirm-tab-close' ,
861- } ) ;
862- if ( ! confirmClose ) {
863- return ;
864- }
864+ if ( canCloseTab ( tab ) || ( await confirmClosingTabs ( ) ) ) {
865+ dispatch ( { type : WorkspacesActions . CloseTab , atIndex } ) ;
866+ cleanupLocalAppRegistryForTab ( tab ?. id ) ;
865867 }
866- dispatch ( { type : WorkspacesActions . CloseTab , atIndex } ) ;
867- cleanupLocalAppRegistryForTab ( tab ?. id ) ;
868868 } ;
869869} ;
870870
0 commit comments