Skip to content

fix: Fix links in Announcements #1934

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

Merged
merged 16 commits into from
Aug 11, 2022
Merged
Changes from 3 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 @@ -36,6 +36,7 @@ const Card: React.FC<CardProps> = ({
onClick = undefined,
isLoading = false,
}: CardProps) => {
const stopEvent = (event) => event.stopPropagation();
let card;
let cardContent = (
<>
Expand All @@ -44,7 +45,17 @@ const Card: React.FC<CardProps> = ({
{subtitle && <h3 className="card-subtitle">{subtitle}</h3>}
</header>
<div className="card-body">
{copy && <div className="card-copy">{copy}</div>}
{copy && (
<div
className="card-copy"
role="button"
tabIndex={0}
onClick={stopEvent}
onKeyDown={stopEvent}
>
{copy}
</div>
Copy link
Member

Choose a reason for hiding this comment

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

This creation of a fake button and adding a stop propagation handler to it seems a bit fishy to me.
Could we achieve the same effect by using CSS pointer-events?
Check in https://css-tricks.com/almanac/properties/p/pointer-events/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the link!
I've tried using pointer-events on both child and parent elements, however click event is always propagated to the Card component which results in following the navigation..
Could you be more specific on how we can use pointer-events here?

Copy link
Member

Choose a reason for hiding this comment

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

It is something like this: https://stackoverflow.com/a/46707009

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've tried this suggestion as well, but it didn't work either.. but I might be doing something wrong, I don't have much experience with pointer-events

Another option in my opinion is that eventPropagation can be stopped on the SanitizedHtml level here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if we stop the propagation in the "html_content" level it also works, but for me it's just another workaround and doesn't solve the problem fully

)}
</div>
</>
);
Expand Down