improvement(Table): implement indeterminate checkbox state#3909
improvement(Table): implement indeterminate checkbox state#3909michpetrov wants to merge 3 commits intopatternfly:masterfrom
Conversation
|
PF4 preview: https://patternfly-react-pr-3909.surge.sh |
a25602f to
05da5e8
Compare
|
Okay, I think I fixed the tests; one question regarding Should I add test for "some rows are selected"? |
seanforyou23
left a comment
There was a problem hiding this comment.
Nice work! I think unfortunately we don't yet utilize hooks in patternfly react due to legacy react version support. As much as I'd love to change this, I'd have to ask for the moment - can we refactor this to a class-based solution?
Another thing worth considering is the usage of the name amount - might it better be named cardinalityType? Interested to hear other opinions on this.
|
@seanforyou23 I see |
|
Thx for pointing this out! Checking into what we can do, keep you posted! |
mcarrano
left a comment
There was a problem hiding this comment.
@kriker can you help me out with this one? For bulk selection in a table, I believe the way we said it should work is for selecting the checkbox to clear selection (not select all) when you start with partial selection. That's what I remember but I can't find it written down anywhere. Can you confirm? It's currently working the opposite here.
|
@michpetrov |
05da5e8 to
2461b02
Compare
|
Refactored the component, rebased the branch. There is still the one test failing, I don't know what it is testing so I don't know what to fix. |
|
@michpetrov I'll take a look later today and see if I can help find out what gives with the test. Thanks for the refactoring! |
|
Hi there @michpetrov - just a heads up I sent a PR to your working branch - seems to be related to this commit bd3f49f Looking into the issue I think I found some problems that while unrelated to this work item - is impacted by it. I'm going to see if I can isolate the unrelated problem (described in the cypress test) without these changes and maybe that will fix the problem without having to do anything further here. It's just a guess at this point though, so feel free to proceed investigating on your end with the demo I provided in the mean time. Hope it helps, keep you posted! |
| compact = 'compact' | ||
| } | ||
|
|
||
| export enum SelectedRowsAmount { |
There was a problem hiding this comment.
Do you think we could assign strings to represent these enum values? I think using the enum indices is really elegant but makes it a little difficult to debug when comparing against the resulting markup. In other words I thought data-rowsamount="1" meant there was a single row selected instead of it referring to "some".
| ) => { | ||
| const { | ||
| extraParams: { onSelect, allRowsSelected, rowLabeledBy = 'simple-node' } | ||
| extraParams: { onSelect, allRowsSelected, selectedRowsAmount, rowLabeledBy = 'simple-node' } |
There was a problem hiding this comment.
If we no longer need allRowsSelected, can we remove it?
There was a problem hiding this comment.
I'll remove it, I kept it in in case something depended on it.
| 'aria-labelledby': rowLabeledBy + rowIndex | ||
| } | ||
| : { | ||
| checked: allRowsSelected, |
There was a problem hiding this comment.
Seems like this may be what's causing that test to fail.
2461b02 to
2c1000f
Compare
2c1000f to
24173b6
Compare
3d31538 to
3220c67
Compare
|
@seanforyou23 I've changed the failing test and added your cypress tests |
dlabrecq
left a comment
There was a problem hiding this comment.
Looking... Can you please rebase to fix the merge conflict?
3220c67 to
97474e0
Compare
|
@dlabrecq rebased |
97474e0 to
1d8b828
Compare
1d8b828 to
d7f1dad
Compare
dlabrecq
left a comment
There was a problem hiding this comment.
After reviewing the code, I realized we already have a "Bulk select table" feature, which performs the same functionality and more. It shows how many items are selected, it selects one or more pages at a time, etc.
Do we want to support both features?
See http://patternfly-react.surge.sh/documentation/react/demos/bulkselecttable
Regarding the example itself, I found the behavior a little confusing. I expect the "select all" toggle to show the same behavior as if I manually clicked on each checkbox. That is, similar to the "Bulk select table" example.
- When I click the "select all" toggle, all checkboxes are selected, including the disabled one.
- When I select each checkbox manually, the "select all" toggle is shown in the indeterminate state. I presume that's because one of the checkboxes is disabled and cannot be selected.
- Now if I click on the "select all" toggle, then deselect each checkbox manually, the "select all" toggle remains in an indeterminate state. I cannot deselect the remaining checkbox because it's disabled. I have to select all again, then deselect all to remove the selection.
|
I think that @dlabrecq makes some good points. This show work in the same way as the bulk selection from the toolbar. The only reason to still include this was for cases where you might want to use a table without a toolbar. |
|
I can see how the bulk selection could work if you have a toolbar, but at the same time it will increase the size of the toolbar, which might already be full enough. Unless the select all functionality in the Table will be deprecated I believe having a select-all checkbox that can be indeterminate makes sense I've got a question: If the user would never select all due to the Table contents but you still want to display that something has been selected, how would you go about doing that without a the select-all or bulk select component? |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |



What: Closes #3648
Added indeterminate state; this cannot be achieved simply through HTML attributes, hence the use of hooks. Left in the
allRowsSelectedprop in case it's used somewhere but it's made redundant with this change.(Kinda new to React, please correct me if I went against conventions)