Skip to content
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

[core] Duplication between Floating UI and Base UI #454

Open
oliviertassinari opened this issue Jun 11, 2024 · 2 comments
Open

[core] Duplication between Floating UI and Base UI #454

oliviertassinari opened this issue Jun 11, 2024 · 2 comments
Assignees
Labels
core Infrastructure work going on behind the scenes

Comments

@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 11, 2024

Summary

I'm opening this issue for the future, after we see product market fit. I don't think that we should care too much about this now.

But after, it seems that we have an opportunity to remove code duplication between Base UI and Floating UI to reduce the bundle size, and avoid fixing bugs twice. The duplications that I could see:

  1. use-isomorphic-layout-effect vs. @mui/utils/useEnhancedEffect
  2. floating useId vs. @mui/utils/useId
  3. FocusGuard vs. FocusTrap. This one might be the trickest. Part of the design decision of FocusTrap was explicitly to not depend on tabbable to avoid its bundle size and rely on the browser instead. [Modal] Better focus management material-ui#15450 dive
    a bit into it. Also, [FocusTrap] Trap to only focus on tabbable elements material-ui#23827 is interesting as show that there are strong different ways to approach this.
@oliviertassinari oliviertassinari added status: waiting for maintainer These issues haven't been looked at yet by a maintainer core Infrastructure work going on behind the scenes labels Jun 11, 2024
@atomiks
Copy link
Contributor

atomiks commented Jun 13, 2024

Since 1 and 2 are small utilities, I don't think they're too major to worry about right now

For 3, to support tabbable portals, the FocusGuard solution works robustly across all formats (keyboard, touch, screen readers). The tabbable dependency is indeed used internally in Floating UI, as it handles complex scenarios with shadow roots in spite of the extra bundle size. Floating UI also only lets tabbable elements receive focus, unless there is nothing tabbable to focus, then it focuses the popover itself as a fallback. In general I don't think focusing non-tabbable elements is a good thing because they aren't interactive - the screen reader virtual cursor is what "focuses" those elements.

@atomiks atomiks removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jun 13, 2024
@oliviertassinari
Copy link
Member Author

oliviertassinari commented Jun 13, 2024

@atomiks one of the limitations with using tababble focus-trap/tabbable#167 (comment)

@michaldudak michaldudak assigned atomiks and unassigned michaldudak Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes
Projects
None yet
Development

No branches or pull requests

3 participants