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

[Components - Popover]: Fix regression of inbetween inserter in site editor #42329

Merged
merged 4 commits into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

- `BoxControl`: Change ARIA role from `region` to `group` to avoid unwanted ARIA landmark regions ([#42094](https://github.com/WordPress/gutenberg/pull/42094)).
- `FocalPointPicker`, `FormTokenField`, `ResizableBox`: Fixed SSR breakage ([#42248](https://github.com/WordPress/gutenberg/pull/42248)).
- `Popover`: pass missing anchor ref to the `getAnchorRect` callback prop. ([#42076](https://github.com/WordPress/gutenberg/pull/42076))
- `ComboboxControl`: use custom prefix when generating the instanceId ([#42134](https://github.com/WordPress/gutenberg/pull/42134).
- `Popover`: pass missing anchor ref to the `getAnchorRect` callback prop. ([#42076](https://github.com/WordPress/gutenberg/pull/42076)).
- `Popover`: call `getAnchorRect` callback prop even if `anchorRefFallback` has no value. ([#42329](https://github.com/WordPress/gutenberg/pull/42329)).

### Internal

Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/popover/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Set this prop to `false` to disable focus changing entirely. This should only be

### placement

The direction in which the popover should open relative to its parent node or anchor node.
The direction in which the popover should open relative to its parent node or anchor node.

The available base placements are 'top', 'right', 'bottom', 'left'.

Expand Down Expand Up @@ -137,7 +137,7 @@ A callback function which is used to override the anchor value computation algor

If you need the `DOMRect` object i.e., the position of popover to be calculated on every time, the popover re-renders, then use `getAnchorRect`.

`getAnchorRect` callback function receives a reference to the popover anchor element as a function parameter and it should return a `DOMRect` object.
`getAnchorRect` callback function receives a reference to the popover anchor element as a function parameter and it should return a `DOMRect` object. Noting that `getAnchorRect` can be called with `null`.

- Type: `Function`
- Required: No
4 changes: 2 additions & 2 deletions packages/components/src/popover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const Popover = (
return anchorRef.ownerDocument;
} else if ( anchorRect && anchorRect?.ownerDocument ) {
return anchorRect.ownerDocument;
} else if ( getAnchorRect && anchorRefFallback.current ) {
} else if ( getAnchorRect ) {
return (
getAnchorRect( anchorRefFallback.current )?.ownerDocument ??
document
Expand Down Expand Up @@ -275,7 +275,7 @@ const Popover = (
return anchorRect;
},
};
} else if ( getAnchorRect && anchorRefFallback.current ) {
} else if ( getAnchorRect ) {
usedRef = {
getBoundingClientRect() {
const rect = getAnchorRect( anchorRefFallback.current );
Expand Down