New Features
-
feat(useDismiss): add two mechanisms to cancel an
outsidePress
dismissal (#1983)A custom guard to cancel the outside press if the event is inside a certain element:
useDismiss(context, { // enabled, but can return false to cancel outsidePress: (event) => !event.target.closest('.toast'), });
-
For
FloatingTree
s, add the ability to register a node to a customparentId
, bypassing<FloatingNode />
lookups. A sibling floating element can mark itself as a child of another sibling despite not being inside its React tree. (#1983)const nodeId = useFloatingNodeId(customParentId);
-
feat(FloatingFocusManager): add
visuallyHiddenDismiss
option. Inmodal
mode, this appends and/or prepends a visually hidden dismiss buttons for when an explicit close button is not available, e.g. a root Menu component or a portaled combobox’s listbox. This allows a floating component to be dismissed without the user needing to select anything when they do not have anesc
key available. (#1985)
Refactors
-
refactor: significantly improve focus handling throughout the library (Manager, useFocus/ListNavigation/Click hooks) (#1985)
- There is much better support for iOS and VoiceOver on Safari
- Portals combined with non-modal focus management now work correctly
focusItemOnOpen
works with touch screen readers- Comboboxes work more smoothly with FloatingFocusManager
- Several misc edge case bugs fixed with
useListNavigation
-
🚨 BREAKING(FloatingFocusManager): Due to the improved focus management system, floating elements without tabbable content that use the
useListNavigation
hook (e.g. Menu, Select) should always explicitly setinitialFocus={-1}
onFloatingFocusManager
to prevent focus conflicts. This has been added to the documentation. (#1985)<FloatingFocusManager context={context} initialFocus={-1}> {/* floating element */} </FloatingFocusManager>
-
⚠️ refactor(FloatingPortal): portal content by default no longer injects itself into a single root node with a default id of
floating-ui-root
. Instead the portals have a unique id and get removed from the DOM when the FloatingPortal’s host component unmounts — when specifying anid
this logic can be bypassed however as it is assumed the node is static or controlled elsewhere. This better supports the new focus management system. (#1985)
Bug Fixes
-
fix(useInnerOffset): check
scrollRef
onScroll (#1986)When using keyboard nav to navigate list items, the offset did not change to expand the floating element's height when scrolling programmatically
-
fix(useHover): for
safePolygon
, switch frompointermove
tomousemove
to reduce flakyness, particularly in Firefox (#1990) -
fix(useEvent): work around minifier bug that prevented the callback from being freshly set (#1995)
-
fix: export
ExtendedRefs
type (#1992)