-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Implement Floating UI for positioning floating elements #14139
Comments
floating-ui
for positioning floating elements
floating-ui
for positioning floating elementsfloating-ui
for positioning floating elements
I did some exploration into floating-ui after you presented a bit about it last Friday @tay1orjones. It definitely feels like a good solution to some of the issues that are linked above (popover elements inside of modals, ie OverflowMenus, Dropdowns, menu button issues). It also addresses #6551, allowing floating menus to auto align based on available space. I have put together two prototypes using
|
@kurtwaldowski-b right now Datepicker isn't on the list because it doesn't have any alignment or positioning options/props. The only reason to add floating-ui to it would be to avoid the issue of it being clipped within another component like a modal. To my knowledge we don't have an issue reporting that. Could you provide an example in a stackblitz of it not working properly? With that reproduction we can open a new issue for it. |
Thanks! Do you know if the floating-ui updates will be applied to IconButtons? We are still seeing IconButton tooltips being cut off by parent containers for example: Curious as well on autoAlign Thanks! |
Following up here; this update should be applied to both Buttons and IconButtons for consistent behavior. I opened the following to address it with a stackblitz: #17168 Its forcing us to do some wonky things like add a Tooltip around an IconButton and then hide the built in tooltip with styling :/ |
@rodet just opened an issue in our repo on |
Follow-on work for Floating UI. |
The problem
All across the system we have components that render various types of floating elements. Each of these cannot be rendered via a portal because it fails SC 1.3.2: meaningful sequence.
Due to this, there are a bunch of situations where floating elements don't render properly above other elements:
Modal
Issues already resolved by this workstream
MenuButton
menu items remain fixed on page scroll #14296@carbon/react
Menu, MenuButton #15521autoAlign
prop is set, and the viewport is too small, caret / popover positioning is off #15566Popover's
autoAlign
prop was a step towards attempting to rectify this situation by adding some logic for overflow detection and reflow #11508, but it has a few limitations/drawbacks:Proposed solution
Use floating-ui for positioning of floating elements.
It's licensed MIT, has an intuitive api, is extensible, and is quickly becoming a de-facto solution for this type of positioning. It's the successor to the popular popper.js library.
It includes collision detection and we could enable the feature behind experimental props.
There are ready-made packages for react, react-native, and vue. The
@floating-ui/dom
package can be used for other framework implementations of Carbon (web components, angular, etc).It's worth mentioning Radix UI and Fluent UI Web are using it, as are some others
This also could open up the possibility for more easily implementing advanced positioning features such as:
Questions and concerns
General items, open questions to resolve
autoAlign
collision detection #17018@carbon/react
@carbon/react
Dropdown #15865@carbon/react
ComboBox #16470@carbon/react
MultiSelect and FilterableMultiSelect #16507@carbon/react
Menu, MenuButton #15521@carbon/react
ComboButton #16540@carbon/react
new OverflowMenu (behind theenable-v12-overflowmenu
flag) #16541@carbon/react
implementation #16542detectOverflow
configurable collision boundary #16879autoAlign
to Button for IconButton's tooltip #17168@carbon/ibm-products
@carbon/ibm-products
Coachmarks ibm-products#5356@carbon/ibm-products
TagSet ibm-products#5354@carbon/ibm-products
TagOverflow ibm-products#5355@carbon/ibm-products
ActionBar ibm-products#5357The text was updated successfully, but these errors were encountered: