Skip to content

Commit

Permalink
Fix amp search result links (#125)
Browse files Browse the repository at this point in the history
* Fix hrefs on search suggestions in AMP.

* bump version
  • Loading branch information
markbrocato authored Aug 7, 2020
1 parent 0db349a commit 5b15e89
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-storefront",
"version": "8.15.0",
"version": "8.15.1",
"description": "Build and deploy e-commerce progressive web apps (PWAs) in record time.",
"module": "./index.js",
"license": "Apache-2.0",
Expand Down
7 changes: 5 additions & 2 deletions src/link/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,13 @@ const Link = ({ as, href, prefetch, prefetchURL, pageData, onClick, children, ..
</NextLink>
)
} else {
const child = React.Children.only(children)
const passHref = !child.props.href // we only passHref if the child does not have an href prop already. This fixes a bug with AMP where NextLink overrides and escapes amp-bind syntax in hrefs.

// This way we can get a ref of Material-ui components
return (
// This way we can get a ref of Material-ui components
<RootRef rootRef={ref}>
<NextLink href={href} prefetch={false} as={as} passHref>
<NextLink href={href} prefetch={false} as={as} passHref={passHref}>
{React.cloneElement(children, {
onClick: handleClick,
...other,
Expand Down
2 changes: 1 addition & 1 deletion src/search/SearchSuggestionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function SearchSuggestionItem({
{children ? (
children
) : (
<a>
<a href={item.as}>
<div data-ui={ui}>
<ImageComponent
className={classes.thumbnail}
Expand Down

0 comments on commit 5b15e89

Please sign in to comment.