Skip to content
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

Rename enableFilters to enableFilterRow #2195

Merged
merged 1 commit into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
- `onPaste`
- `onSelectedCellChange`
- ⚠️ This replaces the `onCellSelected` and `onCellDeSelected` props
- `enableFilters`
- `enableFilterRow`
- ⚠️ This replaces the `enableHeaderFilters` and `column.filterable` props
- `filters`
- `onFiltersChange`
Expand Down
10 changes: 5 additions & 5 deletions src/DataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export interface DataGridProps<R, SR = unknown> extends SharedDivProps {
* Toggles and modes
*/
/** Toggles whether filters row is displayed or not */
enableFilters?: boolean;
enableFilterRow?: boolean;
cellNavigationMode?: CellNavigationMode;

/**
Expand Down Expand Up @@ -199,7 +199,7 @@ function DataGrid<R, SR>({
onFill,
onPaste,
// Toggles and modes
enableFilters = false,
enableFilterRow = false,
cellNavigationMode = 'NONE',
// Miscellaneous
editorPortalTarget = document.body,
Expand Down Expand Up @@ -236,9 +236,9 @@ function DataGrid<R, SR>({
* computed values
*/
const [gridRef, gridWidth, gridHeight] = useGridDimensions();
const headerRowsCount = enableFilters ? 2 : 1;
const headerRowsCount = enableFilterRow ? 2 : 1;
const summaryRowsCount = summaryRows?.length ?? 0;
const totalHeaderHeight = headerRowHeight + (enableFilters ? headerFiltersHeight : 0);
const totalHeaderHeight = headerRowHeight + (enableFilterRow ? headerFiltersHeight : 0);
const clientHeight = gridHeight - totalHeaderHeight - summaryRowsCount * rowHeight;
const isSelectable = selectedRows !== undefined && onSelectedRowsChange !== undefined;

Expand Down Expand Up @@ -895,7 +895,7 @@ function DataGrid<R, SR>({
sortDirection={sortDirection}
onSort={onSort}
/>
{enableFilters && (
{enableFilterRow && (
<FilterRow<R, SR>
columns={viewportColumns}
filters={filters}
Expand Down
6 changes: 3 additions & 3 deletions stories/demos/HeaderFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function HeaderFilters() {
developer: '',
complete: ''
});
const [enableFilters, setEnableFilters] = useState(true);
const [enableFilterRow, setEnableFilterRow] = useState(true);

const columns = useMemo((): Column<Row>[] => {
const developerOptions = Array.from(new Set(rows.map(r => r.developer))).map(d => ({
Expand Down Expand Up @@ -158,7 +158,7 @@ export function HeaderFilters() {
}

function toggleFilters() {
setEnableFilters(!enableFilters);
setEnableFilterRow(!enableFilterRow);
}

return (
Expand All @@ -171,7 +171,7 @@ export function HeaderFilters() {
<DataGrid
columns={columns}
rows={filteredRows}
enableFilters={enableFilters}
enableFilterRow={enableFilterRow}
filters={filters}
onFiltersChange={setFilters}
/>
Expand Down