Open tay1orjones opened 1 year ago
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 https://github.com/carbon-design-system/carbon/issues/6551, allowing floating menus to auto align based on available space.
I have put together two prototypes using floating-ui
to do some research here, one that is most akin to the new MenuButton
component and another to add that new MenuButton
to Carbon for IBM Products Datagrid to test in context.
Is this still in scope for Q1 this year? Thanks!
@kurtwaldowski-b Yes, but we had to break this up into different phases. The initial phase to add this to Popover
, Tooltip
, Toggletip
and Slug
has been delivered in https://github.com/carbon-design-system/carbon/pull/14654 and should go out in @carbon/react@1.54.0
. We're targeting the remaining pieces for Q2.
Thanks! One additional question; will these updates also impact date pickers (flatpickr), or should a separate issue be opened for them? Edit Just saw this mentioned above in questions and concerns
@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.
@kurtwaldowski-b Yes, but we had to break this up into different phases. The initial phase to add this to
Popover
,Tooltip
,Toggletip
andSlug
has been delivered in #14654 and should go out in@carbon/react@1.54.0
. We're targeting the remaining pieces for Q2.
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!
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
DataTable
General tooltip
Popover
Previously marked complete
Popover's
autoAlign
prop was a step towards attempting to rectify this situation by adding some logic for overflow detection and reflow carbon-design-system/carbon#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