fix: Search takes too much priority from cmd+k trigger
This commit is contained in:
@@ -42,8 +42,10 @@ function CommandBar() {
|
||||
t("Type a command or search")
|
||||
}…`}
|
||||
/>
|
||||
<CommandBarResults />
|
||||
{ui.showModKHint && (
|
||||
<CommandBarResults
|
||||
prioritizeSearchResults={ui.commandBarOpenedFromSidebar}
|
||||
/>
|
||||
{ui.commandBarOpenedFromSidebar && (
|
||||
<Hint size="small" type="tertiary">
|
||||
<QuestionMarkIcon size={18} color="currentColor" />
|
||||
{t(
|
||||
@@ -77,14 +79,10 @@ const Hint = styled(Text)`
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
background: ${(props) => props.theme.secondaryBackground};
|
||||
border-top: 1px solid ${(props) => props.theme.background};
|
||||
margin: 1px 0 0;
|
||||
padding: 6px 16px;
|
||||
width: 100%;
|
||||
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
`;
|
||||
|
||||
const Positioner = styled(KBarPositioner)`
|
||||
|
||||
@@ -3,15 +3,24 @@ import { orderBy } from "lodash";
|
||||
import * as React from "react";
|
||||
import styled from "styled-components";
|
||||
import CommandBarItem from "~/components/CommandBarItem";
|
||||
import { NoSection } from "~/actions/sections";
|
||||
import { SearchSection } from "~/actions/sections";
|
||||
|
||||
export default function CommandBarResults() {
|
||||
type Props = {
|
||||
prioritizeSearchResults: boolean;
|
||||
};
|
||||
|
||||
export default function CommandBarResults(props: Props) {
|
||||
const { results, rootActionId } = useMatches();
|
||||
|
||||
return (
|
||||
<KBarResults
|
||||
items={orderBy(results, (item) =>
|
||||
typeof item !== "string" && item.section === NoSection ? -1 : 1
|
||||
// this is an unfortunate hack until kbar supports priority internally
|
||||
typeof item !== "string" &&
|
||||
item.section === SearchSection &&
|
||||
props.prioritizeSearchResults
|
||||
? -1
|
||||
: 1
|
||||
)}
|
||||
maxHeight={400}
|
||||
onRender={({ item, active }) =>
|
||||
|
||||
@@ -64,7 +64,7 @@ function AppSidebar() {
|
||||
if (isSearching) {
|
||||
history.push(searchPath());
|
||||
} else {
|
||||
ui.enableModKHint();
|
||||
ui.commandBarOpened();
|
||||
query.toggle();
|
||||
}
|
||||
}, [ui, location, history, query]);
|
||||
|
||||
Reference in New Issue
Block a user