material-react-table 1.0.0-beta.10 → 1.0.0-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.0-beta.10",
2
+ "version": "1.0.0-beta.11",
3
3
  "license": "MIT",
4
4
  "name": "material-react-table",
5
5
  "description": "A fully featured Material UI V5 implementation of TanStack React Table V8, written from the ground up in TypeScript.",
@@ -3,6 +3,7 @@ import React, {
3
3
  FC,
4
4
  MouseEvent,
5
5
  useCallback,
6
+ useEffect,
6
7
  useState,
7
8
  } from 'react';
8
9
  import {
@@ -169,6 +170,12 @@ export const MRT_FilterTextField: FC<Props> = ({
169
170
  setAnchorEl(event.currentTarget);
170
171
  };
171
172
 
173
+ useEffect(() => {
174
+ if (column.getFilterValue() === undefined) {
175
+ handleClear();
176
+ }
177
+ }, [column.getFilterValue()]);
178
+
172
179
  if (columnDef.Filter) {
173
180
  return <>{columnDef.Filter?.({ column, header, table })}</>;
174
181
  }
@@ -315,7 +322,7 @@ export const MRT_FilterTextField: FC<Props> = ({
315
322
  ? '120px'
316
323
  : 'auto',
317
324
  width: '100%',
318
- '& .MuiSelect-icon': {
325
+ '& .MuiSelect-icon': {
319
326
  mr: '1.5rem',
320
327
  },
321
328
  ...(textFieldProps?.sx instanceof Function
@@ -1,4 +1,10 @@
1
- import React, { ChangeEvent, MouseEvent, useCallback, useState } from 'react';
1
+ import React, {
2
+ ChangeEvent,
3
+ MouseEvent,
4
+ useCallback,
5
+ useEffect,
6
+ useState,
7
+ } from 'react';
2
8
  import {
3
9
  Collapse,
4
10
  debounce,
@@ -32,6 +38,11 @@ export const MRT_GlobalFilterTextField = <
32
38
  } = table;
33
39
  const { globalFilter, showGlobalFilter } = getState();
34
40
 
41
+ const textFieldProps =
42
+ muiSearchTextFieldProps instanceof Function
43
+ ? muiSearchTextFieldProps({ table })
44
+ : muiSearchTextFieldProps;
45
+
35
46
  const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
36
47
  const [searchValue, setSearchValue] = useState(globalFilter ?? '');
37
48
 
@@ -56,10 +67,11 @@ export const MRT_GlobalFilterTextField = <
56
67
  setGlobalFilter(undefined);
57
68
  };
58
69
 
59
- const textFieldProps =
60
- muiSearchTextFieldProps instanceof Function
61
- ? muiSearchTextFieldProps({ table })
62
- : muiSearchTextFieldProps;
70
+ useEffect(() => {
71
+ if (globalFilter === undefined) {
72
+ handleClear();
73
+ }
74
+ }, [globalFilter]);
63
75
 
64
76
  return (
65
77
  <Collapse