Skip to content

Commit f84b8a8

Browse files
committed
Cleanup
1 parent 65a40c7 commit f84b8a8

File tree

3 files changed

+310
-354
lines changed

3 files changed

+310
-354
lines changed

webview-ui/src/components/settings/SearchableSetting.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { HTMLAttributes } from "react"
1+
import { HTMLAttributes, useEffect } from "react"
22

33
import { cn } from "@/lib/utils"
44

55
import { SectionName } from "./SettingsView"
6+
import { useSearchIndexContext } from "./useSettingsSearch"
67

78
interface SearchableSettingProps extends HTMLAttributes<HTMLDivElement> {
89
/**
@@ -26,8 +27,8 @@ interface SearchableSettingProps extends HTMLAttributes<HTMLDivElement> {
2627
/**
2728
* Wrapper component that marks a setting as searchable.
2829
*
29-
* The search system scans the DOM for elements with `data-searchable` attribute
30-
* and reads the metadata from data attributes to build the search index.
30+
* The component registers itself with the search index context on mount,
31+
* allowing the search system to index settings as they are rendered.
3132
*
3233
* @example
3334
* ```tsx
@@ -53,6 +54,17 @@ export function SearchableSetting({
5354
className,
5455
...props
5556
}: SearchableSettingProps) {
57+
const searchContext = useSearchIndexContext()
58+
59+
// Register this setting with the search index on mount
60+
// Note: We don't unregister on unmount because settings are indexed once
61+
// during the initial tab cycling phase and remain in the index
62+
useEffect(() => {
63+
if (searchContext) {
64+
searchContext.registerSetting({ settingId, section, label })
65+
}
66+
}, [searchContext, settingId, section, label])
67+
5668
return (
5769
<div
5870
data-searchable

0 commit comments

Comments
 (0)