Skip to content

Commit dc3c41c

Browse files
Pollepsjoepio
authored andcommitted
#677 Searchbox only searches current drive + atomicdata.dev by default
1 parent 1cb3c6d commit dc3c41c

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

browser/data-browser/src/components/forms/SearchBox/SearchBox.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface SearchBoxProps {
1818
autoFocus?: boolean;
1919
value: string | undefined;
2020
isA?: string;
21-
scope?: string;
21+
scopes?: string[];
2222
placeholder?: string;
2323
disabled?: boolean;
2424
required?: boolean;
@@ -32,7 +32,7 @@ export function SearchBox({
3232
autoFocus,
3333
value,
3434
isA,
35-
scope,
35+
scopes,
3636
placeholder,
3737
disabled,
3838
required,
@@ -167,7 +167,7 @@ export function SearchBox({
167167
<SearchBoxWindow
168168
searchValue={inputValue}
169169
onChange={setInputValue}
170-
scope={scope}
170+
scopes={scopes}
171171
isA={isA}
172172
placeholder={placeholderText}
173173
triggerRef={triggerRef}

browser/data-browser/src/components/forms/SearchBox/SearchBoxWindow.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ import { focusOffsetElement } from '../../../helpers/focusOffsetElement';
99
import { isURL } from '../../../helpers/isURL';
1010
import { useAvailableSpace } from '../hooks/useAvailableSpace';
1111
import { remToPixels } from '../../../helpers/remToPixels';
12+
import { useSettings } from '../../../helpers/AppSettings';
1213

1314
const BOX_HEIGHT_REM = 20;
1415

1516
interface SearchBoxWindowProps {
1617
searchValue: string;
1718
isA?: string;
18-
scope?: string;
19+
scopes?: string[];
1920
placeholder?: string;
2021
triggerRef: React.RefObject<HTMLButtonElement>;
2122
onExit: (lostFocus: boolean) => void;
@@ -28,13 +29,14 @@ export function SearchBoxWindow({
2829
searchValue,
2930
onChange,
3031
isA,
31-
scope,
32+
scopes,
3233
placeholder,
3334
triggerRef,
3435
onExit,
3536
onSelect,
3637
onCreateItem,
3738
}: SearchBoxWindowProps): JSX.Element {
39+
const { drive } = useSettings();
3840
const [realIndex, setIndex] = useState<number | undefined>(undefined);
3941
const { below } = useAvailableSpace(true, triggerRef);
4042
const wrapperRef = React.useRef<HTMLDivElement>(null);
@@ -45,9 +47,14 @@ export function SearchBoxWindow({
4547
[isA],
4648
);
4749

50+
const parents = useMemo(
51+
() => scopes ?? [drive, 'https://atomicdata.dev'],
52+
[scopes],
53+
);
54+
4855
const { results } = useServerSearch(searchValue, {
4956
filters,
50-
scope,
57+
parents,
5158
});
5259

5360
const isAboveTrigger = below < remToPixels(BOX_HEIGHT_REM);

0 commit comments

Comments
 (0)