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

Abstract away tooltip overlay triggers #1421

Merged
merged 1 commit into from
Sep 27, 2024
Merged

Conversation

axelboc
Copy link
Collaborator

@axelboc axelboc commented Sep 26, 2024

React Bootstrap's abstractions for tooltips is quite verbose. I'm adding a small component to make this a bit more palatable.

I'm also mitigating a very annoying issue, which is that when you click for instance on the "Clear sample list" button and then dismiss the dialog, the button receives focus again, which shows the tooltip.

That's because React Bootstrap's tooltips appear both on hover and on focus for accessibility; this is good but the way it's implemented is far from perfect, since when you close the dialog, you want to give focus back to the button but not show the tooltip... I couldn't find a workaround for this, unfortunately, but a way to mitigate it is to at least close the tooltip when clicking anywhere else on the screen. This is done with the rootClose prop, which was previously set on some tooltips but not all.

Peek 2024-09-26 14-40

@axelboc axelboc marked this pull request as ready for review September 26, 2024 12:53
<div className="me-4">
<b>{cplate_label}</b>
</div>
) : null}
<OverlayTrigger
variant="outline-success"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think this was a valid prop and had any effect.

}
)}
<TooltipTrigger
id="refresh-tooltip"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I changed all the IDs as well, since some of them had been copy-pasted and did not match the purpose of the tooltip.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When we make the switch to React 18, we can generate random IDs with useId()

@marcus-oscarsson
Copy link
Member

Thanks !

@marcus-oscarsson marcus-oscarsson merged commit 8d9522d into develop Sep 27, 2024
10 of 11 checks passed
@marcus-oscarsson marcus-oscarsson deleted the ab-tooltip-trigger branch September 27, 2024 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants