Skip to content

Commit

Permalink
remove onClose from section results as well
Browse files Browse the repository at this point in the history
  • Loading branch information
scazan committed Jul 3, 2024
1 parent 024629b commit 9f5b3f7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 31 deletions.
39 changes: 17 additions & 22 deletions src/components/Search/SearchModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,28 +232,23 @@ function SearchModalBody(
</div>
</div>
{!state.ask || !withAsk ? (
<>
<SearchResults
ref={resultsRef}
spaceId={spaceId}
revisionId={revisionId}
parent={state.global ? parent : null}
query={state.query}
withAsk={withAsk}
onSwitchToAsk={() => {
onChangeQuery({
ask: true,
query: state.query,
global: state.global,
});
}}
onClose={onClose}
>
{parent && state.query ? (
<SearchScopeToggle spaceTitle={spaceTitle} />
) : null}
</SearchResults>
</>
<SearchResults
ref={resultsRef}
spaceId={spaceId}
revisionId={revisionId}
parent={state.global ? parent : null}
query={state.query}
withAsk={withAsk}
onSwitchToAsk={() => {
onChangeQuery({
ask: true,
query: state.query,
global: state.global,
});
}}
>
{parent && state.query ? <SearchScopeToggle spaceTitle={spaceTitle} /> : null}
</SearchResults>
) : null}
{state.query && state.ask && withAsk ? (
<SearchAskAnswer spaceId={spaceId} query={state.query} />
Expand Down
4 changes: 1 addition & 3 deletions src/components/Search/SearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ export const SearchResults = React.forwardRef(function SearchResults(
parent: Site | Collection | null;
withAsk: boolean;
onSwitchToAsk: () => void;
onClose: (to?: string) => void;
},
ref: React.Ref<SearchResultsRef>,
) {
const { children, query, spaceId, revisionId, parent, withAsk, onSwitchToAsk, onClose } = props;
const { children, query, spaceId, revisionId, parent, withAsk, onSwitchToAsk } = props;

const language = useLanguage();
const debounceTimeout = React.useRef<NodeJS.Timeout | null>(null);
Expand Down Expand Up @@ -251,7 +250,6 @@ export const SearchResults = React.forwardRef(function SearchResults(
query={query}
item={item}
active={index === cursor}
onClick={onClose}
/>
);
}
Expand Down
7 changes: 1 addition & 6 deletions src/components/Search/SearchSectionResultItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,15 @@ export const SearchSectionResultItem = React.forwardRef(function SearchSectionRe
query: string;
item: ComputedSectionResult;
active: boolean;
onClick: (to: string) => void;
},
ref: React.Ref<HTMLAnchorElement>,
) {
const { query, item, active, onClick } = props;
const { query, item, active } = props;

return (
<Link
ref={ref}
href={item.href}
onClick={(event) => {
event.preventDefault();
onClick(item.href);
}}
className={tcls(
'search-section-result-item',
'[&:has(+:not(&))]:mb-6',
Expand Down

0 comments on commit 9f5b3f7

Please sign in to comment.