diff --git a/src/components/shared/FormTitle/FilterInput.jsx b/src/components/shared/FormTitle/FilterInput.jsx index 4540c6e39..04b3e969c 100644 --- a/src/components/shared/FormTitle/FilterInput.jsx +++ b/src/components/shared/FormTitle/FilterInput.jsx @@ -33,96 +33,99 @@ const StyledTextField = styled(TextField)` ` export const FilterInput = memo( - observer(({ filterInputIsVisible, ref: inputRef }) => { - const store = useContext(MobxContext) - const { nodeLabelFilter, activeFilterTable: activeFilterTableIn } = - store.tree - // ISSUE: doc is not covered by active node array - // thus activeFilterTable is not set for /Dokumentation - const { pathname } = useLocation() - const isDocs = pathname.includes('/Dokumentation') - const activeFilterTable = isDocs ? 'doc' : activeFilterTableIn + observer( + ({ filterInputIsVisible, toggleFilterInputIsVisible, ref: inputRef }) => { + const store = useContext(MobxContext) + const { nodeLabelFilter, activeFilterTable: activeFilterTableIn } = + store.tree + // ISSUE: doc is not covered by active node array + // thus activeFilterTable is not set for /Dokumentation + const { pathname } = useLocation() + const isDocs = pathname.includes('/Dokumentation') + const activeFilterTable = isDocs ? 'doc' : activeFilterTableIn - const { setKey: setNodeLabelFilterKey, isFiltered: runIsFiltered } = - nodeLabelFilter - const isFiltered = runIsFiltered() + const { setKey: setNodeLabelFilterKey, isFiltered: runIsFiltered } = + nodeLabelFilter + const isFiltered = runIsFiltered() - const filterValue = nodeLabelFilter?.[activeFilterTable] ?? '' - const [value, setValue] = useState(filterValue) - // value should update when changed from outside - useEffect(() => { - if (filterValue === value) return - setValue(filterValue) - }, [filterValue]) + const filterValue = nodeLabelFilter?.[activeFilterTable] ?? '' + const [value, setValue] = useState(filterValue) + // value should update when changed from outside + useEffect(() => { + if (filterValue === value) return + setValue(filterValue) + }, [filterValue]) - const setNodeLabelFilter = useCallback( - (val) => { - setNodeLabelFilterKey({ - value: val, - key: activeFilterTable, - }) - }, - [setNodeLabelFilterKey, activeFilterTable], - ) + const setNodeLabelFilter = useCallback( + (val) => { + setNodeLabelFilterKey({ + value: val, + key: activeFilterTable, + }) + }, + [setNodeLabelFilterKey, activeFilterTable], + ) - const onChange = useCallback((e) => { - // remove some values as they can cause exceptions in regular expressions - const val = e.target.value.replaceAll('(', '').replaceAll(')', '') - setValue(val) - }, []) + const onChange = useCallback((e) => { + // remove some values as they can cause exceptions in regular expressions + const val = e.target.value.replaceAll('(', '').replaceAll(')', '') + setValue(val) + }, []) - const onKeyUp = useCallback( - (e) => { - if (e.key === 'Enter') setNodeLabelFilter(value) - }, - [setNodeLabelFilter, value], - ) + const onKeyUp = useCallback( + (e) => { + if (e.key === 'Enter') setNodeLabelFilter(value) + }, + [setNodeLabelFilter, value], + ) - const onClickEmpty = useCallback(() => { - setValue('') - setNodeLabelFilter('') - }, [setNodeLabelFilter, setValue]) + const onClickEmpty = useCallback(() => { + toggleFilterInputIsVisible() + setValue('') + setNodeLabelFilter('') + }, [setNodeLabelFilter, setValue]) - // if no activeFilterTable, show nothing - if (!activeFilterTable) return null + // if no activeFilterTable, show nothing + if (!activeFilterTable) return null - return ( - - - - - - - - - : null, - }, - }} - /> - - ) - }), + return ( + + + + + + + + + : null, + }, + }} + /> + + ) + }, + ), ) diff --git a/src/components/shared/FormTitle/index.jsx b/src/components/shared/FormTitle/index.jsx index ab5d8cfa4..71f3036e3 100644 --- a/src/components/shared/FormTitle/index.jsx +++ b/src/components/shared/FormTitle/index.jsx @@ -92,6 +92,7 @@ export const FormTitle = memo(