-
Notifications
You must be signed in to change notification settings - Fork 38
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
Using FloatingUI with Tooltips #1311
Conversation
@mayank99 Checkpoint if the approach is correct: |
On the contrary, I think this hook should be moved inside the Tooltip file. Tooltip is very different from Menu, so it would be better not to share code. In general looks ok so far, other than three comments.
|
That div comes from FloatingPortal I am using to portal tooltip on given element. I think we could use just one portal (new one). They provide hook (if we need it): https://floating-ui.com/docs/FloatingPortal#usefloatingportalnode
We can easily override aria props. I added appendTo which goes to portal element. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mayank99 I think this is in a good shape for review.
|
||
const context = data.context; | ||
|
||
const hover = useHover(context); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be allow users to customise interactions? eg. disable tooltip on focus.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be nice to give control, but i fear that developers will start removing focus as trigger, making tooltips inaccessible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not giving control for now. We can add that later.
autoUpdate(referenceEl, floatingEl, update, { | ||
animationFrame: followTrigger, | ||
}), | ||
middleware: [offset(5), flip(), shift()], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow users to customise middleware?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. see iTwin/iTwinUI-react#783 and iTwin/iTwinUI-react#947
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe adding prop would be ok?
middleware?: {
offset?: number;
flip?: boolean;
..etc;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, lets control all the names now. Other option would be to allow user to pass any and all middleware, but then they might start doing weird things
I also think it should be possible for the user to toggle autoUpdate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
autoUpdateOptions were added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. 🚀
One more thing I would like to see is the ability to switch between aria-describedby
vs aria-labelledby
vs no aria. This will allow us to use <Tooltip>
inside <IconButton>
. But it can be done in a future PR.
Another thing we should do is add FloatingDelayGroup
inside ButtonGroup
. Again can be done in a future PR.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: Annie D <22462084+LostABike@users.noreply.github.com>
Changes
Added
FloatingUI
and used it in Tooltip:Tooltip
to use floatingUI.Testing
Docs