diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 6502be591e1..801e691e573 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -1051,8 +1051,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation // MSFT 33353327: We're purposefully not using _initializedTerminal to ensure we're fully initialized. // Doing so makes us return nullptr when XAML requests an automation peer. // Instead, we need to give XAML an automation peer, then fix it later. - if (!_IsClosing()) + if (!_IsClosing() && !_detached) { + // It's unexpected that interactivity is null even when we're not closing or in detached state. + THROW_HR_IF_NULL(E_UNEXPECTED, _interactivity); + // create a custom automation peer with this code pattern: // (https://docs.microsoft.com/en-us/windows/uwp/design/accessibility/custom-automation-peers) if (const auto& interactivityAutoPeer{ _interactivity.OnCreateAutomationPeer() })