-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[Popper][base-ui] Replace or refactor to use Floating UI #32587
Comments
cc @michaldudak |
We don't plan to do anything breaking in the v5 timeframe, so you're safe to use whatever we currently have. We'll likely upgrade to Floating UI at some point, as we generally want to use the latest dependencies. If upgrading from Popper to Floating UI cause breaking changes, we'll do it in the next major. cc @mnajdova (as the co-owner of this component) |
The plan sounds good to me 👍 |
Sounds good, thanks for the info! |
I have added this issue to #30660 and added the Pros:
Cons:
Benchmark |
Floating UI has a page for the pros https://floating-ui.com/docs/motivation#comparison-with-popper-style-api So what could be the cons ? The refactoring cost ? |
This issue should be labeled as a
There are many resolved bugs in Floating-UI in the past few months (when Popperjs didn't receive updates).
|
@o-alexandrov it's lighter but not that much lighter. It depends what features you import though, as each piece is tree-shakeable (within reason). https://bundlejs.com is the best source to check. For example, for common usage:
|
@atomiks most importantly, do you agree on labeling as a You can compare weight on bundlephobia, bundlejs, etc. for a general idea of the weight. However, to know the precise difference, you should compare it postbundling, achieving feature-parity.
My weight observation is based on making changes in the Menu component from MUI.
|
We might be able to rely entirely on CSS with https://drafts.csswg.org/css-anchor-position/ to solve the positioning problem. I think within 3 years. It's detailed a bit in https://developer.chrome.com/blog/tether-elements-to-each-other-with-css-anchor-positioning/. I raised the opportunity in #35914 (comment). What I conclude from this is that using One last thought, is there a CSS |
There's a polyfill for CSS anchor positioning using |
It would be great, if the end users wouldn't have to download floating-ui (as it'd improve Lighthouse LCP everyone has issues with), if their browsers support CSS anchor positioning. In other words, imho, this feature should be conditionally dynamically imported w/ a polyfill (mentioned above), but not shipped to everyone. It doesn't matter the polyfill is large, two-thirds of users are typically supported within first weeks of the browsers' API release, so on average the data transfer should decrease comparing to shipping floating-ui to everyone, especially in web-based mobile apps and for 100% of Electron (desktop) users due to the bundled latest version of Chromium. |
@o-alexandrov the main problem is that it appears CSS doesn't completely replace all of Floating UI's features, namely uncertainties with same-placement overflow prevention (shifting), arrows, boundaries, virtual elements, available space size, inline elements, cross-document anchoring, shadow DOM, virtual/software keyboards on iOS, pinch-zooming, etc. I guess it depends on what features MUI wants or needs, but some of those are quite fundamental. I'm not sure if shipping a polyfill (rather than something pure) is something a library should be doing 🤔 . I didn't realize the polyfill was that large which is unfortunate, shipping 50 kB to 1/3 of users, especially browsers other than Chrome/old iOS (it would especially affect mobile users), doesn't seem great. Waiting for wider support seems like a better path to me — the positioning part of Floating UI could get smaller anyway if it detects native CSS can be used for core parts, reducing bundle size. |
@atomiks imho, the ideal for MUI would be: flowchart
1{Browser supports CSS anchor positioning}
1 --> |No| 2{Have enough time for a more complex fallback}
1 --> |Yes| 3[use CSS anchor positioning]
2 --> |Yes| 4[load floating-ui dynamically, so the fallback is minimal in size]
2 --> |No| 5[load CSS anchor positioning polyfill dynamically]
Unfortunately, in the source code of
Are you saying there are plans on adding a dynamic import for CSS anchor positioning to |
@michaldudak On the topic what to do with the
Otherwise,
|
With https://floating-ui.com/ aiming to replace Popper.js, I was wondering what are your plans with regards to
Popper
component. Are you planning to deprecate it, refactor it to use Floating UI or any other changes?I wanted to know if I can use it without worring too much if it will get changed soon.
Thank you for your time 🙏
The text was updated successfully, but these errors were encountered: