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

Icon tooltip: Fix console error with a wrapper span #2322

Merged
merged 1 commit into from
Sep 3, 2020
Merged
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
25 changes: 16 additions & 9 deletions lib/icon-button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,22 @@ type OwnProps = {
type Props = OwnProps;

export const IconButton = ({ icon, title, ...props }: Props) => (
<Tooltip
classes={{ tooltip: 'icon-button__tooltip' }}
enterDelay={200}
title={title}
>
<button className="icon-button" type="button" data-title={title} {...props}>
{icon}
</button>
</Tooltip>
<span>
<Tooltip
classes={{ tooltip: 'icon-button__tooltip' }}
enterDelay={200}
title={title}
>
Copy link
Member

Choose a reason for hiding this comment

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

did you try wrapping the <button> from inside the <Tooltip>?

I interpreted the error as a wrapper from inside <Tooltip> vs. wrapping <Tooltip>

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought I tried that first. Lemme see.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yeah. I tried that and it leads to the tooltip being misaligned:

Screen Shot 2020-09-03 at 2 23 06 PM

Copy link
Member Author

Choose a reason for hiding this comment

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

@dmsnell Okay I figured it out! #2324

<button
className="icon-button"
type="button"
data-title={title}
{...props}
>
{icon}
</button>
</Tooltip>
</span>
);

export default IconButton;