Skip to content

Commit 1ade3cd

Browse files
Avoid duplicate hero CTAs on error pages
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
1 parent 744e0e5 commit 1ade3cd

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

app/components/errors.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,23 @@ function ErrorPage({
7272
possibleMatchesQuery?: string
7373
heroProps: HeroSectionProps
7474
}) {
75-
const resolvedHeroProps: HeroSectionProps = possibleMatches?.length
76-
? {
77-
...heroProps,
78-
arrowUrl: '#possible-matches',
79-
arrowLabel: 'Possible matches',
80-
}
81-
: articles?.length
75+
// Only inject the "arrow down" helper link when the caller didn't provide an
76+
// explicit action. Otherwise, it can create duplicate CTAs (notably on 404s).
77+
const resolvedHeroProps: HeroSectionProps = heroProps.action
78+
? heroProps
79+
: possibleMatches?.length
8280
? {
8381
...heroProps,
84-
arrowUrl: '#articles',
85-
arrowLabel: 'But wait, there is more!',
82+
arrowUrl: '#possible-matches',
83+
arrowLabel: 'Possible matches',
8684
}
87-
: heroProps
85+
: articles?.length
86+
? {
87+
...heroProps,
88+
arrowUrl: '#articles',
89+
arrowLabel: 'But wait, there is more!',
90+
}
91+
: heroProps
8892
return (
8993
<>
9094
<noscript>

0 commit comments

Comments
 (0)