Skip to content

Conversation

@just-be-dev
Copy link
Contributor

@just-be-dev just-be-dev commented Nov 6, 2022

Closes #854

This PR updates our tooltip implementation to use floating-ui. Previously we were using react-popper which is now in maintenance mode in favor of floating UI. Overall floating UI provides a more robust, composable API that's generic enough to be applied to any floating UI situation like tooltips, dropdown menus, etc.

I've also integrated the elevation tokens which were added in #1284.

I've tried to keep the baseline implementation as close to the original as possible to minimize changes. Eventually I'd like to be able to generically attach a tooltip to any element (and not have it tied to the underlying button like we have here), but that can wait until there's a specific usecase.

image

image

image

@vercel
Copy link

vercel bot commented Nov 6, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
console-ui-storybook ✅ Ready (Inspect) Visit Preview Nov 8, 2022 at 10:34PM (UTC)

@david-crespo
Copy link
Collaborator

Don't know if this needs to be fixed here or not, but it doesn't behave nicely when it's getting cut off like this (this is the Ladle story for FieldLabel with tip):

image

@just-be-dev
Copy link
Contributor Author

Yeah @david-crespo this is something I think I need to follow up on upstream. So it seems it's only picking between the four primary sides (top, left, bottom, right) instead of doing what would be right in this situation by selecting bottom-start. It seems like this behavior is intentional based on the docs so I'll start a conversation and see what shakes out.

@just-be-dev
Copy link
Contributor Author

So, yeah. Placements for the autoplacement middleware are ultimately chosen by this getPlacementList function. When no alignment option is passed to the middleware it uses only the sides (top, bottom, left, right). We can add an alignment (start or end), but that will only give you that set of alignments. I suspect what we actually want is an ordered list of all alignments starting with the base sides, then start, then end.

I'll work to put together a minimal reproduction and open up an issue upstream.

Copy link
Collaborator

@david-crespo david-crespo left a comment

Choose a reason for hiding this comment

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

Very clean. floating-ui looks great.

@david-crespo
Copy link
Collaborator

I do have one use case that's not the FieldLabel and not a button: #641

Something to follow up on is adding a short delay (maybe default on but configurable): https://floating-ui.com/docs/FloatingDelayGroup

@just-be-dev
Copy link
Contributor Author

I'm going to go ahead and merge this. I'll work to have an upstream issue w/ a small replication of the rendering out of bounds issue we saw. Will follow up with breaking it down to be able to attach tooltips to other items too.

@just-be-dev just-be-dev merged commit 6a8ee0d into main Nov 9, 2022
@just-be-dev just-be-dev deleted the elevation-impl branch November 9, 2022 16:27
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.

Redo tooltip component

3 participants