Eui: EuiInMemoryTable ignores initial pagination props

Created on 4 Apr 2019  路  4Comments  路  Source: elastic/eui

This isn't really related to https://github.com/elastic/eui/issues/1007, since this is affecting initial props. So, if the component starts out with anything other than its default/initial pagination prop eg:

const pagination = {pageIndex: 2, pageSize: 10};

<EuiInMemoryTable
  pagination={pagination}
  ...
/>

I think it's because getInitialPagination does not return anything if pagination does exist:
https://github.com/elastic/eui/blob/master/src/components/basic_table/in_memory_table.js#L95

Maybe reimplementing it to something like this might fix it:

const getInitialPagination = (pagination) => pagination || {};
engineer bug good first issue

All 4 comments

I'm unable to replicate this issue, can you provide a demo of the bug (e.g. with https://codesandbox.io)?

For testing, I've added

pagination={{ initialPageSize: 4, pageSizeOptions: [2, 4, 8] }}

to the example at src-docs/src/views/tables/in_memory/in_memory.js and get this result:

in memory table initial pagination

Please try it with:

pagination = {pageIndex: 2, pageSize: 10};

In some cases we want to initiate/start a table at page 3 for example.

This relates to https://github.com/elastic/kibana/issues/32663, unfortunately angular does not update react components but instead redraws them anytime there is a change from the scope

Ah, gotcha. I mis-read your pageIndex: 2 key/value.

re: https://github.com/elastic/kibana/pull/34565/files#diff-f5c2be5f354e6067ab8d71ff231e2077

I can't see us changing the names of these props (so the mapping in the above PR will need to remain), but it does make sense to support an initial page index.

Was this page helpful?
0 / 5 - 0 ratings