start-ui-web icon indicating copy to clipboard operation
start-ui-web copied to clipboard

"Showing 1 to 0 of 0 results" in DataList footer

Open yoannfleurydev opened this issue 3 years ago β€’ 2 comments

Maybe we must fix the display in footer, "Showing 1 to 0 of 0 results" seems to be not good ?

Originally posted by @Jessy-BAER in https://github.com/BearStudio/start-ui-web/issues/257#issuecomment-1225248162

yoannfleurydev avatar Aug 25 '22 08:08 yoannfleurydev

Hi @yoannfleurydev , in the start-ui-web/src/components/Pagination/index.tsx file, there is :

export const getPaginationInfo = ({
  page = 1,
  pageSize = 10,
  totalItems = 0,
}) => {
  const firstItemOnPage = (page - 1) * pageSize + 1;
  ...

at line 22. So, (1-1)*10+1 = 0+1 = 1.

Due to that, it will always show "Showing 1 to 0" at least. Am I right?

Hugo-Nortier avatar Aug 25 '22 16:08 Hugo-Nortier

Hi @yoannfleurydev , in the start-ui-web/src/components/Pagination/index.tsx file, there is :

export const getPaginationInfo = ({
  page = 1,
  pageSize = 10,
  totalItems = 0,
}) => {
  const firstItemOnPage = (page - 1) * pageSize + 1;
  ...

at line 22. So, (1-1)*10+1 = 0+1 = 1.

Due to that, it will always show "Showing 1 to 0" at least. Am I right?

That's right, the default computation will return 1. We can probably do some check to get 0 or maybe add a skeleton while data is fetching.

yoannfleurydev avatar Sep 19 '22 15:09 yoannfleurydev