@@ -195,6 +195,53 @@ describe("ListView", () => {
195195 expect ( items [ lastIndex ] ) . toHaveAttribute ( "tabindex" , "-1" ) ;
196196 } ) ;
197197
198+ it ( "should not handle keyboard navigation when modifier keys are pressed" , ( ) => {
199+ renderListViewWithHeight ( ) ;
200+ const container = screen . getByRole ( "grid" ) ;
201+
202+ fireEvent . focus ( container ) ;
203+
204+ // Store initial state - first item should be focused
205+ const initialItems = container . querySelectorAll ( ".mx_item" ) ;
206+ expect ( initialItems [ 0 ] ) . toHaveAttribute ( "tabindex" , "0" ) ;
207+ expect ( initialItems [ 2 ] ) . toHaveAttribute ( "tabindex" , "-1" ) ;
208+
209+ // Test ArrowDown with Ctrl modifier - should NOT navigate
210+ fireEvent . keyDown ( container , { code : "ArrowDown" , ctrlKey : true } ) ;
211+
212+ let items = container . querySelectorAll ( ".mx_item" ) ;
213+ expect ( items [ 0 ] ) . toHaveAttribute ( "tabindex" , "0" ) ; // Should still be on first item
214+ expect ( items [ 2 ] ) . toHaveAttribute ( "tabindex" , "-1" ) ; // Should not have moved to third item
215+
216+ // Test ArrowDown with Alt modifier - should NOT navigate
217+ fireEvent . keyDown ( container , { code : "ArrowDown" , altKey : true } ) ;
218+
219+ items = container . querySelectorAll ( ".mx_item" ) ;
220+ expect ( items [ 0 ] ) . toHaveAttribute ( "tabindex" , "0" ) ; // Should still be on first item
221+ expect ( items [ 2 ] ) . toHaveAttribute ( "tabindex" , "-1" ) ; // Should not have moved to third item
222+
223+ // Test ArrowDown with Shift modifier - should NOT navigate
224+ fireEvent . keyDown ( container , { code : "ArrowDown" , shiftKey : true } ) ;
225+
226+ items = container . querySelectorAll ( ".mx_item" ) ;
227+ expect ( items [ 0 ] ) . toHaveAttribute ( "tabindex" , "0" ) ; // Should still be on first item
228+ expect ( items [ 2 ] ) . toHaveAttribute ( "tabindex" , "-1" ) ; // Should not have moved to third item
229+
230+ // Test ArrowDown with Meta/Cmd modifier - should NOT navigate
231+ fireEvent . keyDown ( container , { code : "ArrowDown" , metaKey : true } ) ;
232+
233+ items = container . querySelectorAll ( ".mx_item" ) ;
234+ expect ( items [ 0 ] ) . toHaveAttribute ( "tabindex" , "0" ) ; // Should still be on first item
235+ expect ( items [ 2 ] ) . toHaveAttribute ( "tabindex" , "-1" ) ; // Should not have moved to third item
236+
237+ // Test normal ArrowDown without modifiers - SHOULD navigate
238+ fireEvent . keyDown ( container , { code : "ArrowDown" } ) ;
239+
240+ items = container . querySelectorAll ( ".mx_item" ) ;
241+ expect ( items [ 0 ] ) . toHaveAttribute ( "tabindex" , "-1" ) ; // Should have moved from first item
242+ expect ( items [ 2 ] ) . toHaveAttribute ( "tabindex" , "0" ) ; // Should have moved to third item (skipping separator)
243+ } ) ;
244+
198245 it ( "should skip non-focusable items when navigating down" , async ( ) => {
199246 // Create items where every other item is not focusable
200247 const mixedItems = [
0 commit comments