Skip to content

Commit

Permalink
Autocomplete: fix double popover (#32988)
Browse files Browse the repository at this point in the history
The popover is rendered twice, once inside the rich text tag and once outside. One of the popovers is removed when rich text is deselected, but the other is not.
  • Loading branch information
ellatrix authored and youknowriad committed Jun 28, 2021
1 parent adcea00 commit fa60650
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 0 additions & 1 deletion packages/block-editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ function RichTextWrapper(
children &&
children( { value, onChange, onFocus } ) }
{ isSelected && <RemoveBrowserShortcuts /> }
{ isSelected && autocompleteProps.children }
{ isSelected && (
<FormatEdit
value={ value }
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/autocomplete/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,12 +547,13 @@ function useAutocomplete( {
const activeId = isExpanded
? `components-autocomplete-item-${ instanceId }-${ selectedKey }`
: null;
const hasSelection = record.start !== undefined;

return {
listBoxId,
activeId,
onKeyDown: handleKeyDown,
popover: AutocompleterUI && (
popover: hasSelection && AutocompleterUI && (
<AutocompleterUI
className={ className }
filterValue={ filterValue }
Expand Down

0 comments on commit fa60650

Please sign in to comment.