mirror of
https://github.com/gosticks/react-table.git
synced 2026-12-04 11:41:45 +00:00
fix(usefilters): fix filter type fallback and autoRemove functionality AGAIN
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
module.exports = {
|
||||
hooks: {
|
||||
'pre-commit': 'lint-staged',
|
||||
'prepare-commit-msg': 'exec < /dev/tty && git cz --hook',
|
||||
// 'prepare-commit-msg': 'exec < /dev/tty && git cz --hook',
|
||||
},
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-table",
|
||||
"version": "7.0.0-alpha.10",
|
||||
"version": "7.0.0-alpha.11",
|
||||
"description": "A fast, lightweight, opinionated table and datagrid built on React",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/tannerlinsley/react-table#readme",
|
||||
|
||||
@@ -48,14 +48,12 @@ export const useFilters = props => {
|
||||
filterTypes
|
||||
)
|
||||
|
||||
const { autoRemove } = filterMethod
|
||||
|
||||
return setState(old => {
|
||||
const newFilter =
|
||||
typeof updater === 'function' ? updater(old.filters[id]) : updater
|
||||
|
||||
//
|
||||
if (shouldAutoRemove(autoRemove, newFilter)) {
|
||||
if (shouldAutoRemove(filterMethod.autoRemove, newFilter)) {
|
||||
const { [id]: remove, ...newFilters } = old.filters
|
||||
return {
|
||||
...old,
|
||||
@@ -81,13 +79,13 @@ export const useFilters = props => {
|
||||
Object.keys(newFilters).forEach(id => {
|
||||
const newFilter = newFilters[id]
|
||||
const column = columns.find(d => d.id === id)
|
||||
const autoRemove = getFilterMethod(
|
||||
const filterMethod = getFilterMethod(
|
||||
column.filter,
|
||||
userFilterTypes || {},
|
||||
filterTypes
|
||||
)
|
||||
|
||||
if (shouldAutoRemove(autoRemove, newFilter)) {
|
||||
if (shouldAutoRemove(filterMethod.autoRemove, newFilter)) {
|
||||
delete newFilters[id]
|
||||
}
|
||||
})
|
||||
@@ -220,5 +218,10 @@ function shouldAutoRemove(autoRemove, value) {
|
||||
}
|
||||
|
||||
function getFilterMethod(filter, userFilterTypes, filterTypes) {
|
||||
return isFunction(filter) || userFilterTypes[filter] || filterTypes[filter]
|
||||
return (
|
||||
isFunction(filter) ||
|
||||
userFilterTypes[filter] ||
|
||||
filterTypes[filter] ||
|
||||
filterTypes.text
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user