-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add Table
component
#174
Add Table
component
#174
Conversation
8a7d62d
to
1dc9d7f
Compare
Codecov Report
@@ Coverage Diff @@
## main #174 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 13 14 +1
Lines 158 224 +66
Branches 55 75 +20
=========================================
+ Hits 158 224 +66
Continue to review full report at Codecov.
|
5175bdf
to
c327b26
Compare
e6b7b22
to
65c9079
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found an anti-pattern in the Table
component that should be reviewed. props
should be considered read-only
. In the Table
component, selectedItem
should not be modified. The Table
component should have a state to track the item that is currently focused. It should be autonomous and re-render itself without the need of the parent. You can check this undesired behaviour by using selectedItem={null}
in the TableComponents.js
and interacting with the tables.
I also found that Table
failed to focus on a hidden row if it was at the bottom of the table.
I left a number of other comments. They are merely suggestions, please, do not feel obligated to respond to these.
In the future, have you considered to create a simpler more basic table for scenarios where no selection of items are needed. This static table component should not have hovering effects or clickable behaviour, but still could benefit from the table styling.
* @param {Item|null} currentItem | ||
* @param {number} step | ||
*/ | ||
function nextItem(items, currentItem, step) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another way to move is to loop or cycle (when you reach top, you move to bottom if ArrowUp
is pressed).
I also raised some concerns about touch devices. I think it would be worth considering (1) supporting iOS < 13 and (2) using a single touch to trigger |
There was a verbal conversation today between @esanzgar , @robertknight and myself about the pattern implemented in this We discussed a possible future need for a "dumber" Table, which wouldn't require state control. We're going to wait until a use case arises before implementing this, but we agreed that it may well be useful in the future. I'll work on integrating @esanzgar 's other feedback! |
Thank you @lyzadanger for explaining me that this is a controlled table and that the parent must own the state of the table and update the table accordingly. Some of my comments (especially about the tests) reflected my incorrect understanding. In this regard, maybe the name |
1e708e0
to
aea02d3
Compare
@esanzgar Whew! That feedback put me through my paces. I still want to look again at a few details with a fresh brain tomorrow, but I'm going to go ahead and ping you for a re-review. Given the amount of changes I've integrated, I've pushed a fixup commit to help you with your re-review. I haven't touched any of the keyboard/touch events stuff yet. Might humbly request that we push that out for a follow-up. I think some friction is arising from my approach here, which was to copy over the existing implementation of this component from LMS and do the minimum needed to generalize it. It's hard to find the right line of "good enough" for a common package, I admit! |
aea02d3
to
e1248ea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Good work.
e1248ea
to
16a593c
Compare
This PR adds a
Table
component and examples, and makes a few adjustment to the underlyingtable
pattern to support the component better.Implementation is based on the LMS
Table
component.Here is a video of it in action, including some keyboard navigation:
Table
API changes:columns
prop renamedtableHeaders
; propertyclassName
onTableHeader
objects now namedclasses
classes
andtableClasses
supportTable
behavior and UI changes:Table
s are wrapped in aScrollbox
component (in LMS' implementation, they had a wrapper div, but this has been abstracted and formalized here)Table
will not change height when loading or changing contents. A loading Spinner is absolute-centered, and the minimum Table height accounts for a Spinner.Fixes #157
Depends on #172