-
-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Floating UI within the component instead of store (#2279)
Closes #887 Closes #1595 Closes #2228 The primary purpose of this PR is to move the `@floating-ui/dom` dependency from the `usePopoverStore` hook to the `Popover` component so it can be lazy loaded. In addition, we moved most of the Floating UI-related props to the `Popover` component, which was the original idea, but wasn't viable before without hacks. The only exception is the `placement` prop, to which we need access on components other than `Popover`. This introduces breaking changes on `Popover` and derived components. Those are described in the changesets. --- Finally, the `Tooltip` component has been updated, so it composes `Hovercard` now, which also benefited from the `Popover` changes. The specific `Tooltip` updates are related to the closed issues above.
- Loading branch information
Showing
87 changed files
with
1,377 additions
and
1,014 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
"@ariakit/core": minor | ||
"@ariakit/react-core": minor | ||
"@ariakit/react": minor | ||
--- | ||
|
||
**BREAKING**: Moved props from the `usePopoverStore` hook to the `Popover` component: `fixed`, `gutter`, `shift`, `flip`, `slide`, `overlap`, `sameWidth`, `fitViewport`, `arrowPadding`, `overflowPadding`, `getAnchorRect`, `renderCallback` (renamed to `updatePosition`). ([#2279](https://github.com/ariakit/ariakit/pull/2279)) | ||
|
||
The exception is the `placement` prop that should still be passed to the store. | ||
|
||
**Before**: | ||
|
||
```jsx | ||
const popover = usePopoverStore({ | ||
placement: "bottom", | ||
fixed: true, | ||
gutter: 8, | ||
shift: 8, | ||
flip: true, | ||
slide: true, | ||
overlap: true, | ||
sameWidth: true, | ||
fitViewport: true, | ||
arrowPadding: 8, | ||
overflowPadding: 8, | ||
getAnchorRect: (anchor) => anchor?.getBoundingClientRect(), | ||
renderCallback: (props) => props.defaultRenderCallback(), | ||
}); | ||
|
||
<Popover store={popover} />; | ||
``` | ||
|
||
**After**: | ||
|
||
```jsx | ||
const popover = usePopoverStore({ placement: "bottom" }); | ||
|
||
<Popover | ||
store={popover} | ||
fixed | ||
gutter={8} | ||
shift={8} | ||
flip | ||
slide | ||
overlap | ||
sameWidth | ||
fitViewport | ||
arrowPadding={8} | ||
overflowPadding={8} | ||
getAnchorRect={(anchor) => anchor?.getBoundingClientRect()} | ||
updatePosition={(props) => props.updatePosition()} | ||
/>; | ||
``` | ||
This change affects all the hooks and components that use `usePopoverStore` and `Popover` underneath: `useComboboxStore`, `ComboboxPopover`, `useHovercardStore`, `Hovercard`, `useMenuStore`, `Menu`, `useSelectStore`, `SelectPopover`, `useTooltipStore`, `Tooltip`. | ||
With this change, the underlying `@floating-ui/dom` dependency has been also moved to the `Popover` component, which means it can be lazy loaded. See the [Lazy Popover](https://ariakit.org/examples/popover-lazy) example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
"@ariakit/react-core": patch | ||
"@ariakit/react": patch | ||
--- | ||
|
||
The `Tooltip` component now defaults to use `aria-describedby` instead of `aria-labelledby`. ([#2279](https://github.com/ariakit/ariakit/pull/2279)) | ||
|
||
If you want to use the tooltip as a label for an anchor element, you can use the `type` prop on `useTooltipStore`: | ||
|
||
```jsx | ||
useTooltipStore({ type: "label" }); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@ariakit/react-core": patch | ||
"@ariakit/react": patch | ||
--- | ||
|
||
The `Tooltip` component now supports mouse events. ([#2279](https://github.com/ariakit/ariakit/pull/2279)) | ||
|
||
It's now possible to hover over the tooltip without it disappearing, which makes it compliant with [WCAG 1.4.13](https://www.w3.org/WAI/WCAG21/Understanding/content-on-hover-or-focus.html). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@ariakit/react-core": patch | ||
"@ariakit/react": patch | ||
--- | ||
|
||
Fixed infinite loop on `Portal` with the `preserveTabOrder` prop set to `true` when the portalled element is placed right after its original position in the React tree. ([#2279](https://github.com/ariakit/ariakit/pull/2279)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
492cbdc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
ariakit – ./
ariakit.org
ariakit-git-main-ariakit.vercel.app
ariakit-ariakit.vercel.app
www.ariakit.org