@@ -218,6 +218,56 @@ public void Unhandled_Default_KeyBinding_Does_Not_Block_HotKey (string keyName)
218218 Assert . True ( hotKeyFired ) ;
219219 }
220220
221+ // Copilot - Opus 4.6
222+ /// <summary>
223+ /// A view with Visible = false should not have its HotKey invoked via InvokeCommandsBoundToHotKey.
224+ /// </summary>
225+ [ Fact ]
226+ public void HotKey_Visible_False_Does_Not_Invoke ( )
227+ {
228+ IApplication app = Application . Create ( ) ;
229+ app . Begin ( new Runnable < bool > ( ) ) ;
230+
231+ ScopedKeyBindingView view = new ( ) ;
232+ app ! . TopRunnableView ! . Add ( view ) ;
233+
234+ // Sanity check: hotkey works when visible
235+ app . Keyboard . RaiseKeyDownEvent ( Key . H ) ;
236+ Assert . True ( view . HotKeyCommandInvoked ) ;
237+
238+ // Now hide the view and try again
239+ view . HotKeyCommandInvoked = false ;
240+ view . Visible = false ;
241+ app . Keyboard . RaiseKeyDownEvent ( Key . H ) ;
242+ Assert . False ( view . HotKeyCommandInvoked ) ;
243+ }
244+
245+ // Copilot - Opus 4.6
246+ /// <summary>
247+ /// A SubView of an invisible SuperView should not have its HotKey invoked.
248+ /// </summary>
249+ [ Fact ]
250+ public void HotKey_Invisible_SuperView_SubView_Does_Not_Invoke ( )
251+ {
252+ IApplication app = Application . Create ( ) ;
253+ app . Begin ( new Runnable < bool > ( ) ) ;
254+
255+ View container = new ( ) { Id = "container" } ;
256+ ScopedKeyBindingView subView = new ( ) ;
257+ container . Add ( subView ) ;
258+ app ! . TopRunnableView ! . Add ( container ) ;
259+
260+ // Sanity check: hotkey works when container is visible
261+ app . Keyboard . RaiseKeyDownEvent ( Key . H ) ;
262+ Assert . True ( subView . HotKeyCommandInvoked ) ;
263+
264+ // Hide the container and try again
265+ subView . HotKeyCommandInvoked = false ;
266+ container . Visible = false ;
267+ app . Keyboard . RaiseKeyDownEvent ( Key . H ) ;
268+ Assert . False ( subView . HotKeyCommandInvoked ) ;
269+ }
270+
221271 // tests that test KeyBindingScope.Focus and KeyBindingScope.HotKey (tests for KeyBindingScope.Application are in Application/KeyboardTests.cs)
222272
223273 public class ScopedKeyBindingView : View
0 commit comments