@@ -13,9 +13,10 @@ interface Tag {
13
13
14
14
interface Props {
15
15
tagAmounts : [ tag : string , amount : number ] [ ] ;
16
+ expandSubTags : boolean ;
16
17
}
17
18
18
- const TagTree = ( { tagAmounts : rawTagAmounts } : Props ) => {
19
+ const TagTree = ( { tagAmounts : rawTagAmounts , expandSubTags } : Props ) => {
19
20
const [ tags , setTags ] = useState < Tag [ ] > ( [ ] ) ;
20
21
21
22
useEffect ( ( ) => {
@@ -74,23 +75,28 @@ const TagTree = ({ tagAmounts: rawTagAmounts }: Props) => {
74
75
return (
75
76
< div className = "flex flex-col justify-start items-start relative w-full h-auto flex-nowrap gap-2 mt-1" >
76
77
{ tags . map ( ( t , idx ) => (
77
- < TagItemContainer key = { t . text + "-" + idx } tag = { t } />
78
+ < TagItemContainer key = { t . text + "-" + idx } tag = { t } expandSubTags = { expandSubTags } />
78
79
) ) }
79
80
</ div >
80
81
) ;
81
82
} ;
82
83
83
84
interface TagItemContainerProps {
84
85
tag : Tag ;
86
+ expandSubTags : boolean ;
85
87
}
86
88
87
89
const TagItemContainer = observer ( ( props : TagItemContainerProps ) => {
88
- const { tag } = props ;
90
+ const { tag, expandSubTags } = props ;
89
91
const tagFilters = memoFilterStore . getFiltersByFactor ( "tagSearch" ) ;
90
92
const isActive = tagFilters . some ( ( f : MemoFilter ) => f . value === tag . text ) ;
91
93
const hasSubTags = tag . subTags . length > 0 ;
92
94
const [ showSubTags , toggleSubTags ] = useToggle ( false ) ;
93
95
96
+ useEffect ( ( ) => {
97
+ toggleSubTags ( expandSubTags ) ;
98
+ } , [ expandSubTags ] ) ;
99
+
94
100
const handleTagClick = ( ) => {
95
101
if ( isActive ) {
96
102
memoFilterStore . removeFilter ( ( f : MemoFilter ) => f . factor === "tagSearch" && f . value === tag . text ) ;
@@ -140,7 +146,7 @@ const TagItemContainer = observer((props: TagItemContainerProps) => {
140
146
} `}
141
147
>
142
148
{ tag . subTags . map ( ( st , idx ) => (
143
- < TagItemContainer key = { st . text + "-" + idx } tag = { st } />
149
+ < TagItemContainer key = { st . text + "-" + idx } tag = { st } expandSubTags = { expandSubTags } />
144
150
) ) }
145
151
</ div >
146
152
) : null }
0 commit comments