-
Notifications
You must be signed in to change notification settings - Fork 6
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
All/selected row switch #284
base: main
Are you sure you want to change the base?
Conversation
|
||
|
||
## All/selected data switch | ||
To allow users to filter data records in the data view, add filtering support that displays the applied filter chips. | ||
|
||
The data view toolbar can include a set of filters by passing a React node to the `filters` property. You can use the predefined components `<DataViewFilters>`, `<DataViewTextFilter>`, and `<DataViewCheckboxFilter>` to customize and handle filtering directly in the toolbar. The `<DataViewFilters>` component is a wrapper that allows conditional filtering using multiple attributes. If you need just a single filter, you can use `<DataViewTextFilter>`, `<DataViewCheckboxFilter>`, or a different filter component alone. Props of these filter components are listed in the [props section of this page](#props). | ||
|
||
You can either pass a `value` and `onChange` event to every filter separately, or you can pass `values` and `onChange` to the `<DataViewFilters>` wrapper, which makes them available to its children. Props directly passed to child filters have a higher priority than the "inherited" ones. | ||
|
||
### Filters state | ||
|
||
The `useDataViewFilters` hook manages the filter state of the data view. It allows you to define default filter values, synchronize filter state with URL parameters, and handle filter changes efficiently. | ||
|
||
**Initial values:** | ||
- `initialFilters` object with default filter values (if the filter param allows multiple values, pass an array). | ||
- Optional `searchParams` object for managing URL-based filter state. | ||
- Optional `setSearchParams` function to update the URL when filters are modified. | ||
|
||
The `useDataViewFilters` hook works well with the [React Router](https://reactrouter.com/) library to support URL-based filtering. Alternatively, you can manage the filter state in the URL using `URLSearchParams` and `window.history.pushState` APIs, or other routing libraries. If no URL parameters are provided, the filter state is managed internally. | ||
|
||
**Return values:** | ||
- `filters` object representing the current filter values. | ||
- `onSetFilters` function to update the filter state. | ||
- `clearAllFilters` function to reset all filters to their initial values. | ||
|
||
### All/selected example | ||
This example demonstrates the setup and usage of filters within the data view. It includes text filters for different attributes, the ability to clear all filters, and persistence of filter state in the URL. | ||
|
||
```js file="./AllSelectedExample.tsx" | ||
|
||
``` |
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.
The content seems to be just copied from the filters section, we should describe, what is happening in the new example
onSelect={handleBulkSelect} | ||
/> | ||
} | ||
toggleGroup={<ToggleGroup aria-label="Default with single selectable"> |
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.
we could come up with some better aria label
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.
how about introducing constants for all/selected strings?
It would be nice to add some cypress test coverage - it can be just an e2e test checking that appropriate rows are displayed |
@radekkaluzik did you have a chance to talk with UX about what to do with the toggle buttons if no rows are selected or become unselected? --If we want to hide the toggle group or just disable buttons/switch to appropriate? This should be probably figured out before we merge the example |
All/selected rows switch
https://issues.redhat.com/browse/RHCLOUD-34812
all-selected.mov