Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(next): add max results to search #1466

Merged
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ import {

import Menu, { MenuContext } from './Menu';

const MAX_RESULT_LIST_SIZE = 8;
const MAX_RESULT_LIST_SIZE = 12;
Copy link
Member Author

Choose a reason for hiding this comment

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

@eng618 I bumped the default to 12, will also double check with our designers on this, but easy to update later if needed


// TODO pass magnifying ref for escape/close? keep focus within outline for input,
const GlobalSearchInput = () => {
const data = useStaticQuery(graphql`
query {
Expand All @@ -46,8 +45,8 @@ const GlobalSearchInput = () => {
}
`);

const index = data.localSearchPages.index;
const store = data.localSearchPages.store;
const { index } = data.localSearchPages;
const { store } = data.localSearchPages;

const optionsRef = useRef([]);
const [focusedItem, setFocusedItem] = useState(0);
Expand All @@ -60,6 +59,8 @@ const GlobalSearchInput = () => {
const { toggleNavState, searchIsOpen, isManagingFocus, setIsManagingFocus } =
useContext(NavContext);

const trimmedResults = results.slice(0, MAX_RESULT_LIST_SIZE);

const clearAndClose = useCallback(() => {
setQuery('');
toggleNavState('searchIsOpen', 'close');
Expand Down Expand Up @@ -197,7 +198,7 @@ const GlobalSearchInput = () => {
<Close size={20} description="Clear search" />
</button>
</div>
<Menu onKeyDown={onKeyDown} results={results} />
<Menu onKeyDown={onKeyDown} results={trimmedResults} />
</div>
</MenuContext.Provider>
);
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10109,7 +10109,7 @@ __metadata:
dependencies:
"@carbon/icons-react": "npm:^11.37.0"
gatsby: "npm:^5.13.3"
gatsby-theme-carbon: "npm:^4.0.0-next.8"
gatsby-theme-carbon: "npm:^4.0.0-next.9"
react: "npm:^18.2.0"
react-dom: "npm:^18.2.0"
languageName: unknown
Expand Down Expand Up @@ -11409,7 +11409,7 @@ __metadata:
languageName: unknown
linkType: soft

"gatsby-theme-carbon@npm:^4.0.0-next.8, gatsby-theme-carbon@workspace:packages/gatsby-theme-carbon":
"gatsby-theme-carbon@npm:^4.0.0-next.9, gatsby-theme-carbon@workspace:packages/gatsby-theme-carbon":
version: 0.0.0-use.local
resolution: "gatsby-theme-carbon@workspace:packages/gatsby-theme-carbon"
dependencies:
Expand Down