mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
* Add extra undefined check for table filters
* Logic fix..
- Do not return early, this is mistake!
- Correctly handle empty activeFilter state
(cherry picked from commit 7d844e02be
)
Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
parent
edf02cd817
commit
e89cfd4958
@ -65,8 +65,13 @@ function FilterAddGroup({
|
|||||||
availableFilters: TableFilter[];
|
availableFilters: TableFilter[];
|
||||||
}) {
|
}) {
|
||||||
const filterOptions: TableFilterChoice[] = useMemo(() => {
|
const filterOptions: TableFilterChoice[] = useMemo(() => {
|
||||||
let activeFilterNames =
|
// List of filter names which are already active on this table
|
||||||
|
let activeFilterNames: string[] = [];
|
||||||
|
|
||||||
|
if (tableState.activeFilters && tableState.activeFilters.length > 0) {
|
||||||
|
activeFilterNames =
|
||||||
tableState.activeFilters?.map((flt) => flt.name) ?? [];
|
tableState.activeFilters?.map((flt) => flt.name) ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
availableFilters
|
availableFilters
|
||||||
@ -83,7 +88,7 @@ function FilterAddGroup({
|
|||||||
|
|
||||||
const valueOptions: TableFilterChoice[] = useMemo(() => {
|
const valueOptions: TableFilterChoice[] = useMemo(() => {
|
||||||
// Find the matching filter
|
// Find the matching filter
|
||||||
let filter: TableFilter | undefined = availableFilters.find(
|
let filter: TableFilter | undefined = availableFilters?.find(
|
||||||
(flt) => flt.name === selectedFilter
|
(flt) => flt.name === selectedFilter
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user