Repository: microsoft/terminal (language: cpp)

Issue:
[Settings>Color schemes] : Keyboard focus jumps to first tab, when user activates 'Yes, delete color scheme' button.
### Windows Terminal version

1.12.3472.0

### Windows build number

22509.1011

### Other Software

**Test Environment: **
OS: Windows 11 Version Dev (OS Build 22509.1011)
App: Windows Terminal Preview

### Steps to reproduce

**Repro Steps: **

1.Open Windows Terminal.
2.Open Settings page using 'Ctr+,'
3.Navigate to 'Color schemes' list-item present in left pane via tab ley & press enter.
4.Naviagte to 'Delete color scheme' button via tab key & press enter.
5.A pop-up will gets open.
6.Navigate to 'Yes, delete color scheme' button via tab key & press enter.
7.Observe the issue.

**User Experience: **
Users who rely on keyboard will get impacted here & will have to navigate again from top of the page un-necessarily, if Keyboard focus jumps to first tab on activating 'Yes, delete color scheme' button.

Guideline reference
https://www.w3.org/TR/WCAG21/#focus-order

Attachment : 
[Keyboard focus jumps to first tab, when user activates 'Yes, delete color scheme' button..zip](https://github.com/microsoft/terminal/files/7728455/Keyboard.focus.jumps.to.first.tab.when.user.activates.Yes.delete.color.scheme.button.zip)


### Expected Behavior

Focus should land on next interactive control i.e (Discard changes button), on activating 'Yes, delete color scheme' button.

### Actual Behavior

Keyboard focus jumps to first tab, when user activates 'Yes, delete color scheme' button.

**Note :** 
1.Same issue repro on 'Deleting' profiles also.


Discussion / hints:
Hmm. Seems to be working fine for color schemes, but not profiles as of the Controlsv2 change. 
Which makes sense, when you delete a scheme, the page stays on the ColorSchemes page. But deleting a profile, we bring you to the previous profile, which involves an actual navigation. So, we'd need to manually toss focus back at the new Delete button on that profile.
I have a fix for this in [`dev/migrie/b/11971-refocus-delete`](https://github.com/microsoft/terminal/compare/dev/migrie/b/11971-refocus-delete), but I wanna see how #12296 shakes out first. If we use the scroll viewer like that PR has it, then we don't need me to manually reset the scroll position in this fix. 
@v-rpundir This should have been fixed in Terminal Preview v1.13.10733/v1.13.10734, can you confirm?
Hi @zadjii-msft 

Main issue still not fixed but Note Issue is fixed now as shown below video:
[Still Repro (3).zip](https://github.com/microsoft/terminal/files/8368216/Still.Repro.3.zip)

<img width="151" alt="image" src="https://user-images.githubusercontent.com/86412703/160537580-38f45ca3-e9eb-4545-9807-1beb70fd8233.png">

Thanks :):


Ah. Okay. So that's a different edge case here. 

https://user-images.githubusercontent.com/18356694/160647778-9a198426-b0f2-4426-9c63-3f98102c2475.mp4

 If you delete a scheme, and then the scheme we fall back to is a built-in profile, then the Delete button on that page is disabled, and we fall back to the tab. Okay. Wacky, but okay. 
@v-rpundir Do you think it would be acceptable in this scenario for focus to land on the _previous_ focusable control, rather than the following one? It's pretty trivial to get focus to land on the "Selection Background" button (which is right before the Delete and Discard buttons in the tab order). Getting it to land on Discard would take a good deal more plumbing.

Alternatively, do you think focusing the dropdown at the top of the page would be a good option? We could do that _always_, forcing narrator to always read out the name of the newly selected scheme.
@zadjii-msft Yes it will be good if focus lands on Color Scheme dropdown, given the fact that Screen Reader user will also get aware about Current Color Scheme.
@Saiteja341  This should now be fixed in https://github.com/microsoft/terminal/releases/tag/v1.13.10983.0

Can you confirm and close the bug please?
Closing as fixed now on Windows Terminal Preview Version: 1.13.10984.

Fix patch:
diff --git a/src/cascadia/TerminalSettingsEditor/ColorSchemes.cpp b/src/cascadia/TerminalSettingsEditor/ColorSchemes.cpp
index 80a83607cef..62ccef42f3a 100644
--- a/src/cascadia/TerminalSettingsEditor/ColorSchemes.cpp
+++ b/src/cascadia/TerminalSettingsEditor/ColorSchemes.cpp
@@ -51,6 +51,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
                     break;
                 }
             }
+
+            ColorSchemeListView().Focus(FocusState::Programmatic);
         });
     }
 


Test patch: