diff --git a/assets/js/src/core/modules/asset/editor/types/folder/tab-manager/tabs/list/list-provider.tsx b/assets/js/src/core/modules/asset/editor/types/folder/tab-manager/tabs/list/list-provider.tsx index cc8d8a840..ec9e44245 100644 --- a/assets/js/src/core/modules/asset/editor/types/folder/tab-manager/tabs/list/list-provider.tsx +++ b/assets/js/src/core/modules/asset/editor/types/folder/tab-manager/tabs/list/list-provider.tsx @@ -14,11 +14,11 @@ /* eslint-disable max-lines */ import React, { createContext, useEffect, useMemo, useState } from 'react' -import { isEmpty } from 'lodash' import { type AssetGetGridApiResponse, type GridColumnConfiguration, type GridDetailedConfiguration } from '@Pimcore/modules/asset/asset-api-slice-enhanced' import { type FilterOptions, type TagFilterOptions } from './types/filterTypes' import { defaultFilterOptions } from './constants/filters' import { type RowSelectionState, type SortingState } from '@tanstack/react-table' +import { isEmptyValue } from '@Pimcore/utils/type-utils' interface ICommonListProviderProps { children: React.ReactNode @@ -122,7 +122,7 @@ export const ListFilterOptionsProvider = ({ children }: ListFilterOptionsProvide const filterOptions = useMemo(() => Object.values(filterOptionsMap).reduce((acc, curr) => { acc.columnFilters = [...acc.columnFilters as [], ...curr.columnFilters as []] - if (!isEmpty(curr.includeDescendants)) { + if (!isEmptyValue(curr.includeDescendants)) { acc.includeDescendants = curr.includeDescendants } diff --git a/assets/js/src/core/utils/type-utils.ts b/assets/js/src/core/utils/type-utils.ts new file mode 100644 index 000000000..72d023d86 --- /dev/null +++ b/assets/js/src/core/utils/type-utils.ts @@ -0,0 +1,32 @@ +/** +* Pimcore +* +* This source file is available under two different licenses: +* - Pimcore Open Core License (POCL) +* - Pimcore Commercial License (PCL) +* Full copyright and license information is available in +* LICENSE.md which is distributed with this source code. +* +* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) +* @license https://github.com/pimcore/studio-ui-bundle/blob/1.x/LICENSE.md POCL and PCL +*/ + +export const isEmptyValue = (value: unknown): boolean => { + if (value === null || value === undefined) { + return true + } + + if (typeof value === 'object' && !Array.isArray(value)) { + return Object.keys(value).length === 0 + } + + if (typeof value === 'object' && Array.isArray(value)) { + return value.length === 0 + } + + if (typeof value === 'string') { + return value.trim().length === 0 + } + + return false +}