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 fullofcaffeine committed Jun 25, 2021
1 parent d60fce4 commit 4df6dcb
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 @@ -289,7 +289,6 @@ function RichTextWrapper(
{ isSelected &&
children &&
children( { value, onChange, onFocus } ) }
{ 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 @@ -377,12 +377,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 4df6dcb

Please sign in to comment.