Check that the control exists before we try to focus it (#11635)

## Summary of the Pull Request
When we are on a settings UI tab, `_GetActiveControl` returns a `nullptr`, make sure not to try and focus it in that case

## PR Checklist
* [x] Closes #11633 
* [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [ ] Tests added/passed
* [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx
* [ ] Schema updated.
* [x] I work here

## Validation Steps Performed
No longer crashes
This commit is contained in:
PankajBhojwani 2021-10-29 07:09:41 -07:00 committed by GitHub
parent b90f3605a2
commit a7ce93a357
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -1597,7 +1597,10 @@ namespace winrt::TerminalApp::implementation
// the control here instead.
if (_startupState == StartupState::Initialized)
{
_GetActiveControl().Focus(FocusState::Programmatic);
if (const auto control = _GetActiveControl())
{
control.Focus(FocusState::Programmatic);
}
}
}
CATCH_LOG();