Skip to content

Autocomplete: Cursor position lost when clicking to insert item #50168

@sandymcfadden

Description

@sandymcfadden

Description

Using a custom autocompleter the cursor position is sometimes lost when inserting an item.
If you use your mouse to click on an autocomplete item, the item inserts as expected, but the cursor position is lost and you can't continue typing until you click back into the block.
If you use keyboard controls to insert the item instead, the cursor position is kept as expected.

Step-by-step reproduction instructions

Tried to narrow down to a basic example it can be found here
https://codesandbox.io/p/sandbox/amazing-kilby-pl9v09

  1. Go to https://pl9v09-3000.csb.app/
  2. Click to type in the paragraph block
  3. Type the # character to bring up the autocompleter
  4. Use your mouse to click on one of the items
  5. Notice the cursor is not positioned at the end of the inserted item as expected

Screenshots, screen recording, code snippet

Example code can be found here
https://codesandbox.io/p/sandbox/amazing-kilby-pl9v09

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Metadata

Metadata

Assignees

Labels

[Feature] InserterThe main way to insert blocks using the + button in the editing interface[Feature] Rich TextRelated to the Rich Text component that allows developers to render a contenteditable[Type] BugAn existing feature does not function as intended

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions