-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Table component API #960
Conversation
nextDirection is now optional (instad of null) and therefore moved to the third argument
This commit also fixes a TS error where sortLabel was not declared on the Cell type. It does not differentiate between header and body cells (same as before), which means that users might think that sorting-related props like sortLabel are available on body cells, where they are not. Unfortunately, making the types stricter here will require a larger refactoring around the table utils which are currently shared by the header and body cells alike.
This commit also includes a refactoring around how the sort options are handled, because we want to prevent the column from sorting if a sortLabel is not set. The main change is a new getSortParams util that is called in TableHead before the params are passed to the Table Header.
We should only export the main Table component and relevant types
This reverts commit a94f6a3. The testids are still set as defaults used in other Table components for testing, so it makes seense to keep it in the TableCell as well.
🦋 Changeset detectedLatest commit: 719818d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/sumup/oss-circuit-ui/24GvtW5xYoSx5vth3PwUVyfyqtnQ |
Hey @robinmetral, Thanks! |
Codecov Report
@@ Coverage Diff @@
## next #960 +/- ##
==========================================
- Coverage 91.55% 91.52% -0.04%
==========================================
Files 163 162 -1
Lines 2984 2973 -11
Branches 759 757 -2
==========================================
- Hits 2732 2721 -11
Misses 223 223
Partials 29 29
|
Purpose
As a follow-up to #852 there were a few things we wanted to address around the Table component, as breaking changes for v3:
nextDirection
argument moved to the third position (index, nextDirection, rows
👉index, rows, nextDirection
) and can now beundefined
(instead ofnull
in the previous implementation). This improves the implementation with TypeScript since it becomes an optional parameter.sortable
prop), the previously optionalsortLabel
prop is now enforced. This is an accessibility requirement. If asortLabel
is not provided, the column will not be sortable.sortable
andsortLabel
props are missing, we should not apply the sorting event handlers, styles, etc.TableHeader
,TableRow
andTableCell
components are no longer exported from Circuit. They are only used internally by the Table component and should not be used directly.test-id
s are no longer built into the component. They can still be passed manually. We could also recommend querying by role in testsBONUS (non-breaking): fixed a table header height bug on mobile when words would wrap and rows would become misaligned.
Approach and changes
☝️
Definition of done