Skip to content

Commit

Permalink
Merge pull request #195 from 10up/fix/grid-positioning-ben
Browse files Browse the repository at this point in the history
Fix for grid positioning when text is selected
  • Loading branch information
peterwilsoncc committed Jun 21, 2023
2 parents 127a053 + 977f90b commit 387b7f8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const InsertSpecialCharactersOptions = {
const { name, title, character } = InsertSpecialCharactersOptions;
const type = `special-characters/${ name }`;
let anchorRange;
let anchorRect;

/**
* Register the "Format Type" to create the character inserter.
Expand All @@ -47,12 +48,15 @@ registerFormatType( type, {

anchorRange =
selection.rangeCount > 0 ? selection.getRangeAt( 0 ) : null;

// Pin the Popover to the caret position.
const boundingClientRect = anchorRange
? anchorRange.getBoundingClientRect()
: null;

anchorRect = anchorRange ? () => boundingClientRect : null;
onChange( toggleFormat( value, { type } ) );
};
// Pin the Popover to the caret position.
const anchorRect = () => {
return anchorRange ? anchorRange.getBoundingClientRect() : null;
};
const characters = applyFilters( `${ name }-characters`, Chars );
// Display the character map when it is active.
const specialCharsPopover = isActive && (
Expand Down

0 comments on commit 387b7f8

Please sign in to comment.