@@ -270,4 +270,87 @@ describe('simple quick jumper', () => {
270270 ) ,
271271 ) . toBeFalsy ( ) ;
272272 } ) ;
273+
274+ // https://github.com/ant-design/ant-design/issues/55637
275+ describe ( 'QuickJumper should only accept numeric input' , ( ) => {
276+ it ( 'should filter non-numeric characters in QuickJumper input' , ( ) => {
277+ const { container } = render ( < Pagination total = { 100 } showQuickJumper /> ) ;
278+
279+ const input = container . querySelector (
280+ '.rc-pagination-options-quick-jumper input' ,
281+ ) as HTMLInputElement ;
282+
283+ // Test typing letters with numbers
284+ fireEvent . change ( input , { target : { value : 'abc123def' } } ) ;
285+ expect ( input . value ) . toBe ( '123' ) ;
286+
287+ // Test decimal point (should be filtered)
288+ fireEvent . change ( input , { target : { value : '12.34' } } ) ;
289+ expect ( input . value ) . toBe ( '1234' ) ;
290+
291+ // Test only letters
292+ fireEvent . change ( input , { target : { value : 'test' } } ) ;
293+ expect ( input . value ) . toBe ( '' ) ;
294+
295+ // Test special characters
296+ fireEvent . change ( input , { target : { value : '!@#$%' } } ) ;
297+ expect ( input . value ) . toBe ( '' ) ;
298+ } ) ;
299+
300+ it ( 'should filter non-numeric characters in simple mode' , ( ) => {
301+ const { container } = render ( < Pagination simple total = { 100 } /> ) ;
302+
303+ const input = container . querySelector (
304+ '.rc-pagination-simple-pager input' ,
305+ ) as HTMLInputElement ;
306+
307+ // Test typing letters with numbers
308+ fireEvent . change ( input , { target : { value : 'test5page' } } ) ;
309+ expect ( input . value ) . toBe ( '5' ) ;
310+
311+ // Test special characters with numbers
312+ fireEvent . change ( input , { target : { value : '3@#' } } ) ;
313+ expect ( input . value ) . toBe ( '3' ) ;
314+ } ) ;
315+
316+ it ( 'should handle paste with non-numeric content' , ( ) => {
317+ const { container } = render ( < Pagination total = { 100 } showQuickJumper /> ) ;
318+
319+ const input = container . querySelector (
320+ '.rc-pagination-options-quick-jumper input' ,
321+ ) as HTMLInputElement ;
322+
323+ // Simulate paste with mixed content
324+ fireEvent . change ( input , { target : { value : 'page 42!' } } ) ;
325+ expect ( input . value ) . toBe ( '42' ) ;
326+
327+ // Simulate paste with only text
328+ fireEvent . change ( input , { target : { value : 'goto page' } } ) ;
329+ expect ( input . value ) . toBe ( '' ) ;
330+ } ) ;
331+
332+ it ( 'should work correctly with Enter key after filtering' , ( ) => {
333+ const onChangeFn = jest . fn ( ) ;
334+ const { container } = render (
335+ < Pagination
336+ onChange = { onChangeFn }
337+ defaultCurrent = { 1 }
338+ total = { 100 }
339+ showQuickJumper
340+ /> ,
341+ ) ;
342+
343+ const input = container . querySelector (
344+ '.rc-pagination-options-quick-jumper input' ,
345+ ) as HTMLInputElement ;
346+
347+ // Type numeric value with letters
348+ fireEvent . change ( input , { target : { value : 'abc5xyz' } } ) ;
349+ expect ( input . value ) . toBe ( '5' ) ;
350+
351+ // Press enter
352+ fireEvent . keyUp ( input , { key : 'Enter' , keyCode : 13 , which : 13 } ) ;
353+ expect ( onChangeFn ) . toHaveBeenCalledWith ( 5 , 10 ) ;
354+ } ) ;
355+ } ) ;
273356} ) ;
0 commit comments