You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just a random question - let me know if this is a duplicate:
how can we leverage Fluent's multiselect table components (Table and DataGrid) to implement a controlled table that has selectable rows (let's call them data rows) and NOT selectable loading/skeleton rows?
Suppose we have a table with 2 elements. One row is a data row - it contains useful data; the other is a loading row - it is a simple loading row with no actual data - just a skeleton/shimmer animation.
I want to be able to only select the first row and that's it.
The behavior should be:
main checkbox (header row checkbox) is in a true state, not mixed nor false.
the first row (data row)'s checkbox is in a true state.
the second row (loading row)'s checkbox is not available anyway - the DOM element is a simple div.
Currently, I am able to achieve this behavior by doing an unconventional method:
I programmatically remove the loading row from the items passed to the useTableFeatures hook:
I can see that internally, in the fluentUI\packages\react-components\react-table\library\src\hooks\useTableSelection.ts file, we do have some code that hints to selectable rows:
// Selection state can contain obselete items (i.e. rows that are removed)constselectableRowIds=React.useMemo(()=>{constrowIds=newSet<TableRowId>();for(leti=0;i<items.length;i++){rowIds.add(getRowId?.(items[i])??i);// ^^---- doesn't this seem wrong? // we're basically assigning a number id to a row (`loading row`)// that shouldn't be selectable anyway... (and presumably should have no id)?}returnrowIds;},[items,getRowId]);
I do not know how to progress further from here.
I have the workaround that I've mentioned above, but I am looking for a concrete answer to my question from the beginning.
Expected Behavior
Proposed expected behavior: Fluent should have a documented, official way to describe how we can implement a controlled multiselect table (Table or DataGrid component) that contains different kinds of row items - actual data rows, loading rows, footer rows, etc.
I was not able to find any story and/or documentation in regards to this behavior.
If you want more information on my use case, you can also reach out to me internally - aolariu.
I'm open to collaborate and/or even submit a fix+docs, given enough information on how-to.
Component
Table
Package version
9.55.0
React version
18.2
Environment
Current Behavior
Hi,
Just a random question - let me know if this is a duplicate:
data rows
) and NOT selectable loading/skeleton rows?Suppose we have a table with 2 elements. One row is a
data row
- it contains useful data; the other is aloading row
- it is a simple loading row with no actual data - just a skeleton/shimmer animation.I want to be able to only select the first row and that's it.
The behavior should be:
true
state, notmixed
norfalse
.data row
)'s checkbox is in atrue
state.loading row
)'s checkbox is not available anyway - the DOM element is a simple div.Currently, I am able to achieve this behavior by doing an unconventional method:
I programmatically remove the
loading row
from theitems
passed to theuseTableFeatures
hook:I can see that internally, in the
fluentUI\packages\react-components\react-table\library\src\hooks\useTableSelection.ts
file, we do have some code that hints to selectable rows:I do not know how to progress further from here.
I have the workaround that I've mentioned above, but I am looking for a concrete answer to my question from the beginning.
Expected Behavior
Proposed expected behavior: Fluent should have a documented, official way to describe how we can implement a controlled multiselect table (Table or DataGrid component) that contains different kinds of row items - actual data rows, loading rows, footer rows, etc.
I was not able to find any story and/or documentation in regards to this behavior.
Reproduction
https://stackblitz.com/edit/bzl56nww?file=src%2Fexample.tsx
Steps to reproduce
dev
.mixed
state, even though the onlyselectable rows
are selected!Are you reporting an Accessibility issue?
no
Suggested severity
Medium - Has workaround
Products/sites affected
No response
Are you willing to submit a PR to fix?
yes
Validations
The text was updated successfully, but these errors were encountered: