Skip to content

Commit

Permalink
[Components - Popover]: Fix regression of inbetween inserter in site …
Browse files Browse the repository at this point in the history
…editor (#42329)

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

* add changelog entry

* update readme

* update changelog
  • Loading branch information
ntsekouras authored Jul 12, 2022
1 parent 25cf5df commit 1049ef3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
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

0 comments on commit 1049ef3

Please sign in to comment.