Skip to content

Fully autonomous AI Agents system capable of performing complex penetration testing tasks

fix(detail-navigation): re-seed the sheet search mirror from the controller on open

Sergey Kozyrenko8ca83137a1d5
diff --git a/frontend/src/components/shared/detail-navigation/detail-navigation-sheet.test.tsx b/frontend/src/components/shared/detail-navigation/detail-navigation-sheet.test.tsx
index 0c176f80..a19fc29a 100644
--- a/frontend/src/components/shared/detail-navigation/detail-navigation-sheet.test.tsx
+++ b/frontend/src/components/shared/detail-navigation/detail-navigation-sheet.test.tsx
@@ -505,3 +505,65 @@ describe('DetailNavigationSheet — virtualization (>100 items)', () => {
});
});
});
+
+// Controlled mode (the documented "page-level search box" use case): the parent
+// owns searchQuery, so the sheet's local input mirror must re-seed from the
+// controller when it changes outside the sheet.
+const ControlledSheet = ({ open, query }: { open: boolean; query: string }) => {
+ const nav = useDetailNavigation<Item>({
+ currentId: 'c',
+ getHref,
+ getLabel,
+ getSearchableText,
+ items: ITEMS,
+ onOpenChange: () => {},
+ onSearchQueryChange: () => {},
+ open,
+ searchDebounceMs: 0,
+ searchQuery: query,
+ });
+
+ return (
+ <DetailNavigationSheet<Item>
+ controller={nav}
+ sheetTitle="Items"
+ />
+ );
+};
+
+const renderControlled = (props: { open: boolean; query: string }) =>
+ render(<ControlledSheet {...props} />, {
+ wrapper: ({ children }: { children: ReactNode }) => (
+ <MemoryRouter initialEntries={['/items/c']}>
+ <TooltipProvider>
+ <Routes>
+ <Route
+ element={<>{children}</>}
+ path="/items/:id"
+ />
+ </Routes>
+ </TooltipProvider>
+ </MemoryRouter>
+ ),
+ });
+
+describe('DetailNavigationSheet — controlled search resync', () => {
+ it('reflects an external searchQuery change made while the sheet was closed', () => {
+ const { rerender } = renderControlled({ open: false, query: '' });
+
+ rerender(
+ <ControlledSheet
+ open={false}
+ query="Bravo"
+ />,
+ );
+ rerender(
+ <ControlledSheet
+ open
+ query="Bravo"
+ />,
+ );
+
+ expect(screen.getByRole<HTMLInputElement>('textbox').value).toBe('Bravo');
+ });
+});
diff --git a/frontend/src/components/shared/detail-navigation/detail-navigation-sheet.tsx b/frontend/src/components/shared/detail-navigation/detail-navigation-sheet.tsx
index b8df16fa..6fa7e647 100644
--- a/frontend/src/components/shared/detail-navigation/detail-navigation-sheet.tsx
+++ b/frontend/src/components/shared/detail-navigation/detail-navigation-sheet.tsx
@@ -140,6 +140,14 @@ export function DetailNavigationSheet<T extends { id: string }>({
if (lastOpen !== open) {
setLastOpen(open);
+
+ // Re-seed the input mirror from the controller on open so a controlled
+ // searchQuery changed from outside isn't shown stale. The sheet is modal,
+ // so searchQuery only changes externally while closed — on-open re-seed
+ // suffices and never clobbers in-progress typing.
+ if (open) {
+ setLocalQuery(searchQuery);
+ }
}
if (desiredFocusId !== focusedId) {