Skip to content

Commit

Permalink
Fix read-only tab dialog to cancel tab closing when dismissed (#9573)
Browse files Browse the repository at this point in the history
Currently dismissing "are you sure you wish to close read-only tab or pane" 
dialog by pressing `ESC` will not abort tab closing
(aka the tab will be closed!)

The reason for this, is that we cancel, only if the "Cancel" is pressed
(aka result=PrimaryButton, while ESC returns result=None).

This PR fixes this, by doing what we usually do:
* Putting Cancel in the CloseButton (which is also triggered by ESC)
* Aborting the action if the result is not a Primary Button

However, since we want Cancel to be a default action,
we set CloseButton to be the DefaultButton  in XAML
  • Loading branch information
Don-Vito authored Mar 22, 2021
1 parent 9069fca commit 9bd097f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/cascadia/TerminalApp/Resources/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,10 @@
<value>Do you want to close all tabs?</value>
</data>
<data name="CloseReadOnlyDialog.CloseButtonText" xml:space="preserve">
<value>Close anyway</value>
<value>Cancel</value>
</data>
<data name="CloseReadOnlyDialog.PrimaryButtonText" xml:space="preserve">
<value>Cancel</value>
<value>Close anyway</value>
</data>
<data name="CloseReadOnlyDialog.Title" xml:space="preserve">
<value>Warning</value>
Expand Down
8 changes: 4 additions & 4 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1339,8 +1339,8 @@ namespace winrt::TerminalApp::implementation
{
ContentDialogResult warningResult = co_await _ShowCloseReadOnlyDialog();

// The primary action is canceling the removal
if (warningResult == ContentDialogResult::Primary)
// If the user didn't explicitly click on close tab - leave
if (warningResult != ContentDialogResult::Primary)
{
co_return;
}
Expand Down Expand Up @@ -1736,8 +1736,8 @@ namespace winrt::TerminalApp::implementation
{
ContentDialogResult warningResult = co_await _ShowCloseReadOnlyDialog();

// The primary action is canceling the action
if (warningResult == ContentDialogResult::Primary)
// If the user didn't explicitly click on close tab - leave
if (warningResult != ContentDialogResult::Primary)
{
co_return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/TerminalPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ the MIT License. See LICENSE in the project root for license information. -->
x:Load="False"
x:Name="CloseReadOnlyDialog"
x:Uid="CloseReadOnlyDialog"
DefaultButton="Primary">
DefaultButton="Close">
</ContentDialog>

<ContentDialog
Expand Down

0 comments on commit 9bd097f

Please sign in to comment.