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

Fix getTrackingProps incompatibility with React's casing expectations. #138

Merged
merged 2 commits into from
Jan 22, 2024
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
1 change: 1 addition & 0 deletions src/lib/components/badge/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const VuiBadge = ({ children, className, color, onClick, href, target, tr

if (href) {
return (
// @ts-expect-error Type 'string' is not assignable to type 'HTMLAttributeReferrerPolicy | undefined'.
<Link className={classes} onClick={onClick} to={href} target={target} {...getTrackingProps(track)}>
{children}
</Link>
Expand Down
1 change: 1 addition & 0 deletions src/lib/components/button/BaseButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const BaseButton = forwardRef<HTMLButtonElement | null, Props>(
});

return (
// @ts-expect-error Type 'string' is not assignable to type 'HTMLAttributeReferrerPolicy | undefined'.
<Link
className={wrapperClasses}
to={href}
Expand Down
1 change: 1 addition & 0 deletions src/lib/components/button/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const VuiIconButton = forwardRef<HTMLButtonElement | null, Props>(

if (href) {
return (
// @ts-expect-error Type 'string' is not assignable to type 'HTMLAttributeReferrerPolicy | undefined'.
<Link to={href} target={target} {...props} {...getTrackingProps(track)}>
<button ref={ref}>{buttonIcon}</button>
</Link>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/summary/Summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { VuiText } from "../typography/Text";
const markDownCitations = (summary: string) => {
const citations = extractCitations(summary);
return citations
.reduce((accum, { text, references }, index) => {
.reduce((accum, { text, references }) => {
if (references) {
accum.push(text);

Expand Down
7 changes: 5 additions & 2 deletions src/lib/utils/getTrackingProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ export const getTrackingProps = (track?: boolean) => {
return {
// Protect against tabnabbing.
rel: "noopener",
// Provide information for tracking, e.g. to docs.
referrerpolicy: "no-referrer-when-downgrade"
// Provide information for tracking, e.g. to docs. Technically this should be
// 'referrerpolicy' but React wants it in camel case. This clashes with
// react-router Link's HTMLAttributeReferrerPolicy type definition so we
// have to use @ts-expect-error at callsites that consume this helper.
referrerPolicy: "no-referrer-when-downgrade"
};
}
// Protect against tabnabbing and strip information from the referrer header.
Expand Down