Skip to content

Commit a62781f

Browse files
committed
feat: add useEffect to update expanded categories based on search keyword
1 parent f0b1872 commit a62781f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/features/settings/components/TopicSettings.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useMemo, useState } from 'react'
1+
import { useEffect, useMemo, useState } from 'react'
22
import { AiFillMobile } from 'react-icons/ai'
33
import { BsChevronDown, BsChevronUp, BsFillGearFill, BsFillShieldLockFill } from 'react-icons/bs'
44
import { FaDatabase, FaPaintBrush, FaRobot, FaServer } from 'react-icons/fa'
@@ -58,6 +58,13 @@ export const TopicSettings = () => {
5858
occupation ? [occupation] : ['backend', 'frontend']
5959
)
6060

61+
useEffect(() => {
62+
if (searchKeyword.trim() === '') {
63+
return
64+
}
65+
setExpandedCategories(Object.keys(groupedTags))
66+
}, [searchKeyword, groupedTags])
67+
6168
return (
6269
<SettingsContentLayout
6370
bodyClassName="topicsBottomSpacer"

0 commit comments

Comments
 (0)