Skip to content

Commit

Permalink
Merge pull request #1111 from newrelic/clark/search-fixes
Browse files Browse the repository at this point in the history
Search updates
  • Loading branch information
clarkmcadoo authored Oct 23, 2024
2 parents 141d04e + 4781891 commit 22ba558
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions packages/gatsby-theme-newrelic/src/components/GlobalSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useThrottle } from 'react-use';

import useKeyPress from '../hooks/useKeyPress';
import useThemeTranslation from '../hooks/useThemeTranslation';
import useScrollFreeze from '../hooks/useScrollFreeze';
import { addPageAction } from '../utils/nrBrowserAgent';

import useSearch from './SearchModal/useSearch';
Expand All @@ -31,6 +32,8 @@ const GlobalSearch = ({ onClose }) => {
const [selected, setSelected] = useState(null);
const possibleSelections = results.length + recentQueries.length;

useScrollFreeze(open);

const moveUp = () =>
setSelected((s) => {
if (s == null) return possibleSelections - 1;
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-theme-newrelic/src/components/SEO.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const SEO = ({ title, location, type, children }) => {
"@type": "SearchAction",
"target": {
"@type": "EntryPoint",
"urlTemplate": "${siteUrl}/?q={search_term_string}"
"urlTemplate": "${siteUrl}/search-results/?query={search_term_string}&page=1"
},
"query-input": "required name=search_term_string"
}]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const SearchInput = forwardRef(
>
{isIconClickable ? (
<Link
to={`?q=${value}`}
to={`search-results/?query=${value}&page=1`}
css={css`
color: var(--brand-button-primary-accent);
&:hover {
Expand Down
7 changes: 6 additions & 1 deletion packages/gatsby-theme-newrelic/src/pages/404.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,12 @@ const NotFoundPage = ({
<SearchInput
placeholder={searchTerm}
onFocus={() =>
navigate(`?q=${searchTerm.replaceAll(' ', '+')}`)
navigate(
`search-results/?query=${searchTerm.replaceAll(
' ',
'+'
)}&page=1`
)
}
css={css`
min-width: 200px;
Expand Down

0 comments on commit 22ba558

Please sign in to comment.