@@ -50,6 +50,52 @@ describe('itemRender interaction compatibility', () => {
5050 expect ( onChange ) . not . toHaveBeenCalled ( ) ;
5151 } ) ;
5252
53+ it . each ( [
54+ [ 'default' , false ] ,
55+ [ 'default' , true ] ,
56+ [ 'opaque' , false ] ,
57+ [ 'opaque' , true ] ,
58+ ] as const ) (
59+ 'allows Tab navigation after disabling a focused %s item (shift=%s)' ,
60+ async ( kind , shift ) => {
61+ const Label = ( ) => < span > page</ span > ;
62+ const onChange = jest . fn ( ) ;
63+ const renderPagination = ( disabled : boolean ) => (
64+ < div >
65+ < button data-testid = "before" > Before pagination</ button >
66+ < Pagination
67+ total = { 100 }
68+ disabled = { disabled }
69+ onChange = { onChange }
70+ itemRender = { kind === 'opaque' ? ( ) => < Label /> : undefined }
71+ />
72+ < button data-testid = "after" > After pagination</ button >
73+ </ div >
74+ ) ;
75+ const { container, rerender, getByTestId } = render (
76+ renderPagination ( false ) ,
77+ ) ;
78+ const item = container . querySelector < HTMLElement > (
79+ '.rc-pagination-item-2' ,
80+ ) ;
81+ const control = kind === 'opaque' ? item : item . querySelector ( 'a' ) ;
82+ control . focus ( ) ;
83+ expect ( control ) . toHaveFocus ( ) ;
84+
85+ rerender ( renderPagination ( true ) ) ;
86+ expect ( control ) . toHaveFocus ( ) ;
87+ expect ( control ) . toHaveAttribute ( 'tabindex' , '-1' ) ;
88+ // Disabling activation must still allow the focused item to be left.
89+ expect ( fireEvent . keyDown ( control , { key : 'Enter' } ) ) . toBe ( false ) ;
90+ expect ( fireEvent . keyDown ( control , { key : ' ' } ) ) . toBe ( false ) ;
91+ expect ( onChange ) . not . toHaveBeenCalled ( ) ;
92+
93+ await userEvent . tab ( { shift } ) ;
94+ expect ( getByTestId ( shift ? 'before' : 'after' ) ) . toHaveFocus ( ) ;
95+ expect ( onChange ) . not . toHaveBeenCalled ( ) ;
96+ } ,
97+ ) ;
98+
5399 it . each ( [
54100 [ 'prev' , 49 ] ,
55101 [ 'next' , 51 ] ,
0 commit comments