Skip to content

WordPress Gutenberg Popover, how to position at the cursor when text is selected? #51307

Answered by bmarshall511
bmarshall511 asked this question in Q&A
Discussion options

You must be logged in to vote

After 2 days, finally got it figured out, got rid of the useAnchorRef and created a var for anchorRange & anchorRect to store the positioning. Would still love to find a way to use the new prop anchor instead of the deprecated prop anchor for the Popover component. I'll leave this ? open in hopes someone has an idea.

import {
	registerFormatType,
	toggleFormat
} from '@wordpress/rich-text';
import { Fragment } from '@wordpress/element';
import { BlockControls, RichTextShortcut } from '@wordpress/block-editor';
import { Popover, ToolbarButton, ToolbarGroup } from '@wordpress/components';
import { displayShortcut } from '@wordpress/keycodes';
import { __ } from '@wordpress/i18n';

const Ins…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by bmarshall511
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant