1- import { HTMLAttributes } from "react"
1+ import { HTMLAttributes , useEffect } from "react"
22
33import { cn } from "@/lib/utils"
44
55import { SectionName } from "./SettingsView"
6+ import { useSearchIndexContext } from "./useSettingsSearch"
67
78interface 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