nextui icon indicating copy to clipboard operation
nextui copied to clipboard

fix(react-table): Table.Pagination component doesn't update with Table.Body

Open cyanxiao opened this issue 3 years ago • 2 comments

Closes #543

📝 Description

Updating <Table /> component can be a usual action, as mentioned in #543. However, <Table.Pagination> does not update synchronically with <Table.Body />, which results in two bugs:

  1. <Table.Pagination /> length doesn't change. So when rows number is larger after the update, some pages can not be selected via <Table.Pagination />.
  2. When rows number is smaller comparing to the previous table, the original page of <Table.Pagination /> is automatically selected and a blank table is showed.3.

This is because:

  1. The table context collection never updates when rows data change.
  2. <Pagination /> is not properly controlled as it does not receive the page prop.

⛳️ Current behavior (updates)

#543 described it thoroughly. I've added a new story here so it would be clearer to test.

before

🚀 New behavior

after

💣 Is this a breaking change (Yes/No): No

📝 Additional Information

cyanxiao avatar Jun 17 '22 08:06 cyanxiao

As agreed with @imchell, I will add some test cases to his PR.

danielsimao avatar Jun 22 '22 17:06 danielsimao

Codecov Report

Merging #549 (3421c4f) into main (d3c7f53) will increase coverage by 1.25%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #549      +/-   ##
==========================================
+ Coverage   74.75%   76.00%   +1.25%     
==========================================
  Files         200      200              
  Lines        3090     3101      +11     
  Branches      952      956       +4     
==========================================
+ Hits         2310     2357      +47     
+ Misses        765      729      -36     
  Partials       15       15              
Impacted Files Coverage Δ
packages/react/src/table/table-pagination.tsx 85.71% <ø> (+71.42%) :arrow_up:
packages/react/src/table/table-context.tsx 84.00% <100.00%> (+2.18%) :arrow_up:
packages/react/src/card/card.tsx 100.00% <0.00%> (ø)
packages/react/src/button/button.tsx 94.00% <0.00%> (ø)
packages/react/src/popover/popover-trigger.tsx 100.00% <0.00%> (ø)
packages/react/src/dropdown/dropdown-trigger.tsx 100.00% <0.00%> (ø)
packages/react/src/utils/collections.ts 83.07% <0.00%> (+1.53%) :arrow_up:
packages/react/src/use-pagination/index.ts 100.00% <0.00%> (+2.43%) :arrow_up:
packages/react/src/pagination/pagination.tsx 68.42% <0.00%> (+2.63%) :arrow_up:
packages/react/src/table/table.tsx 93.54% <0.00%> (+3.22%) :arrow_up:
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update d3c7f53...3421c4f. Read the comment docs.

codecov-commenter avatar Jun 26 '22 04:06 codecov-commenter

Fixed here https://github.com/nextui-org/nextui/pull/626

jrgarciadev avatar Nov 05 '22 01:11 jrgarciadev