diff --git a/packages/sn-pickers-react/src/components/picker/picker-helper.tsx b/packages/sn-pickers-react/src/components/picker/picker-helper.tsx index 1f58f7db7..ef15db309 100644 --- a/packages/sn-pickers-react/src/components/picker/picker-helper.tsx +++ b/packages/sn-pickers-react/src/components/picker/picker-helper.tsx @@ -1,6 +1,6 @@ import { CircularProgress, Link } from '@material-ui/core' import { Repository } from '@sensenet/client-core' -import React from 'react' +import React, { memo } from 'react' import { usePickerHelper } from './picker-helper.hook' type ReferenceFieldHelperProps = { @@ -80,4 +80,5 @@ export const PickerHelper = ({ ) } -export default PickerHelper + +export default memo(PickerHelper, (prevProps, nextProps) => prevProps.contextPath === nextProps.contextPath) diff --git a/packages/sn-pickers-react/src/components/picker/picker.tsx b/packages/sn-pickers-react/src/components/picker/picker.tsx index cb634487f..e02268c34 100644 --- a/packages/sn-pickers-react/src/components/picker/picker.tsx +++ b/packages/sn-pickers-react/src/components/picker/picker.tsx @@ -133,10 +133,15 @@ export const Picker: React.FunctionComponent> = (pro }, [term, props.repository, props.selectionRoots]) const handleJumpToCurrentPath = (path: string) => { - setMode(PickerModes.TREE) - setTerm('') - console.log('handleJumpToCurrentPath', path, navigationPath) setNavigationPath(path) + + if (term?.length && term.length > 0) { + debouncedQuery('') + } + + if (mode !== PickerModes.TREE) { + setMode(PickerModes.TREE) + } } return ( @@ -167,7 +172,6 @@ export const Picker: React.FunctionComponent> = (pro onChange={(ev) => { debouncedQuery(ev.target.value) }} - value={term} /> ({ parentId ?? (items?.[0] ? undefined : PathHelper.getParentPath(path)), ) - console.log(parentResult) if (!parentResult) { return items } diff --git a/packages/sn-pickers-react/src/hooks/use-tree-picker.ts b/packages/sn-pickers-react/src/hooks/use-tree-picker.ts index bf3a48eed..fe933dd1a 100644 --- a/packages/sn-pickers-react/src/hooks/use-tree-picker.ts +++ b/packages/sn-pickers-react/src/hooks/use-tree-picker.ts @@ -60,7 +60,7 @@ export const useTreePicker = repository.load({ @@ -86,9 +86,7 @@ export const useTreePicker = 1 && roots?.includes(path)) { - console.log('roots', roots) - + if ((roots?.length ?? 0) > 1 && (roots?.includes(path) || roots?.includes(navigationPath!))) { result.unshift({ ...(ConstantContent.EMPTY_CONTENT as T), isParent: true,