Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions frontend/src/components/common/Search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ const Search: React.FC<SearchProps> = ({
const ref = useRef<ComponentRef<'input'>>(null);

useEffect(() => {
if (ref.current !== null && value) {
ref.current.value = value;
const qParam = searchParams.get('q') || '';
if (ref.current !== null) {
ref.current.value = qParam;
}
}, [value]);
}, [searchParams]);
Comment on lines +35 to +39
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change breaks the controlled component pattern used in ACLPage/List/List.tsx. When value and onChange props are provided, the component should sync with the value prop, not with URL search parameters.

Consider checking if onChange is provided to determine the mode:

useEffect(() => {
  if (ref.current !== null) {
    if (onChange && value !== undefined) {
      // Controlled mode: sync with value prop
      ref.current.value = value;
    } else {
      // URL-based mode: sync with searchParams
      const qParam = searchParams.get('q') || '';
      ref.current.value = qParam;
    }
  }
}, [onChange, value, searchParams]);

Copilot uses AI. Check for mistakes.

const handleChange = useDebouncedCallback((e) => {
if (ref.current != null) {
Expand Down
Loading