Link dialog jumps when changing formatting while it's open.
Description
If the link dialog is open, changing the format of the highlighted word can cause the link dialog to move on the screen. I'm able to reproduce this in both Safari and Firefox.
This was originally reported on WordPress trac by Wordpress.org user bjornsennbrink.
Step-by-step reproduction instructions
- Set your desktop browser with to around 1327px wide
- Go to the edit post screen
- Enter some text
- Highlight a word you wish to link
- Click the link button in the toolbar
- Press CMD+B on your keyboard
- The link dialog jumps on the screen.
On the original report, it was jumping each time the user pressed cmd+b but I've only been able to reproduce it jumping once. This is possibly worth testing at additional browser widths.
Expected behaviour
Highlighted text to bold, the dialogs position is unaffected.
Actual behaviour
Highlighted text does bold, the dialog jumps.
Screenshots or screen recording (optional)
Safari 14.0.3

Firefox Developer Edition 88.0b9

Code snippet (optional)
WordPress information
- WordPress version: Trunk (5.8-alpha-50427-src)
- Gutenberg version: WP version, plugin not activated.
- Are all plugins except Gutenberg deactivated? Yes
- Are you using a default theme (e.g. Twenty Twenty-One)? Yes
Device information
- Device: Desktop
- Operating system: macOS Big Sur 11.2.3
- Browser: Safari 14.0.3, Firefox Developer Edition 88.0b9
I can reproduce with Gutenberg from trunk and Chrome 89 on macOS 10.12. I've seen a similar thing elsewhere. It seems likely to be rooted in the Popover component.
What i found so far is that sometimes the calculated clientRect of the anchorRef always delivers false values (everything is 0) https://github.com/WordPress/gutenberg/blob/trunk/packages/components/src/popover/index.js#L87
I think that at some point the dom manipulation make the element loose the relation to their parentElement and therefore the clientRect can not be calculated. But this is only a guess and i could not debug so far to prove this.
I'm going to close the issue. I can no longer reproduce the bug.