File tree Expand file tree Collapse file tree
x-pack/platform/plugins/private/upgrade_assistant
__jest__/client_integration/es_deprecations
public/application/components/es_deprecations Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -294,6 +294,34 @@ describe('ES deprecations table', () => {
294294 expect ( find ( 'esDeprecationsPagination' ) . find ( '.euiPagination__item' ) . length ) . toEqual ( 1 ) ;
295295 expect ( find ( 'deprecationTableRow' ) . length ) . toEqual ( reindexDeprecations . length ) ;
296296 } ) ;
297+
298+ it ( 'maintains correct row state across pagination' , async ( ) => {
299+ const { find, actions } = testBed ;
300+
301+ // Verify we have multiple pages
302+ expect ( find ( 'esDeprecationsPagination' ) . find ( '.euiPagination__item' ) . length ) . toBeGreaterThan (
303+ 1
304+ ) ;
305+
306+ // Get the message of the first deprecation on page 1
307+ const firstDeprecationMessagePage1 = find ( 'deprecationTableRow' ) . at ( 0 ) . text ( ) ;
308+
309+ // Navigate to page 2
310+ await actions . pagination . clickPaginationAt ( 1 ) ;
311+
312+ // Get the message of the first deprecation on page 2
313+ const firstDeprecationMessagePage2 = find ( 'deprecationTableRow' ) . at ( 0 ) . text ( ) ;
314+
315+ // The first items on different pages should be different
316+ expect ( firstDeprecationMessagePage1 ) . not . toEqual ( firstDeprecationMessagePage2 ) ;
317+
318+ // Navigate back to page 1
319+ await actions . pagination . clickPaginationAt ( 0 ) ;
320+
321+ // Verify the first deprecation on page 1 is still the same
322+ const firstDeprecationMessagePage1Again = find ( 'deprecationTableRow' ) . at ( 0 ) . text ( ) ;
323+ expect ( firstDeprecationMessagePage1Again ) . toEqual ( firstDeprecationMessagePage1 ) ;
324+ } ) ;
297325 } ) ;
298326
299327 describe ( 'no deprecations' , ( ) => {
Original file line number Diff line number Diff line change @@ -385,9 +385,16 @@ export const EsDeprecationsTable: React.FunctionComponent<Props> = ({
385385 ) : (
386386 < EuiTableBody >
387387 { visibleDeprecations . map ( ( deprecation , index ) => {
388+ // Calculate the absolute index in the full deprecations array
389+ // This ensures stable keys across pagination
390+ // For example: with 10 items per page:
391+ // - Page 1: firstItemIndex=0, keys will be deprecation-row-0 to deprecation-row-9
392+ // - Page 2: firstItemIndex=10, keys will be deprecation-row-10 to deprecation-row-19
393+ // This prevents React from reusing components incorrectly when navigating between pages
394+ const absoluteIndex = pager . firstItemIndex + index ;
388395 return (
389- < React . Fragment key = { `deprecation-row-${ index } ` } >
390- { renderTableRow ( deprecation , mlUpgradeModeEnabled , index ) }
396+ < React . Fragment key = { `deprecation-row-${ absoluteIndex } ` } >
397+ { renderTableRow ( deprecation , mlUpgradeModeEnabled , absoluteIndex ) }
391398 </ React . Fragment >
392399 ) ;
393400 } ) }
You can’t perform that action at this time.
0 commit comments