Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User autocompleter keeps trying to match when it shouldn't, slows-down the editor #30640

Closed
fullofcaffeine opened this issue Apr 8, 2021 · 2 comments · Fixed by #30649
Closed
Labels
[Package] Components /packages/components [Package] Editor /packages/editor [Type] Bug An existing feature does not function as intended

Comments

@fullofcaffeine
Copy link
Member

fullofcaffeine commented Apr 8, 2021

Description

Related to the changes in #29939, which are somewhat incompatible with the UX for the user autocomplete.

Its triggers can happen anywhere and stay on the editor even after the completion is done. Once the autocompleter finds the trigger, it runs through its matching/querying algorithm, but then doesn't know when to stop. What happens is that the text after the trigger starts being considered as part of the text to match and it goes up to infinity.

Step-by-step reproduction instructions

  1. Load the editor by opening a new post or page;
  2. Trigger the user autocompleter by writing @ on the page;
  3. The autocompleter will try to greedily match anything after the @ and won't know where to stop. Keep writing for a while. How long it takes for the slow-down to take place will depend on your browser, computer spec, and how many users you have in your instance (which influences the query);
  4. You can also add a console.debug( match[1] ) here, open the console, and watch as the autocomplete just tries to match anything after @ greedily, even after a selection has already been done.

Expected behaviour

The user autocompleter doesn't try to match/query ad-infinitum and doesn't cause the editor's UI to become slow to respond.

Actual behaviour

The user autocompleter tries to match/query ad-infinitum even after a mismatch.

Screenshots or screen recording (optional)

The output in the console refers to the logging of the match const as I described in step 4 above. You can see that it continues to grow after the trigger and gradually starts to cause some slow-down (which might not be too visible in this video, but it was there):

Peek.2021-04-08.18-14.mp4

WordPress information

  • WordPress version: 5.8-alpha-50689
  • Gutenberg version: 10.3.2 or trunk
  • Are all plugins except Gutenberg deactivated? Yes
  • Are you using a default theme (e.g. Twenty Twenty-One)? Yes

Device information

  • Device: Desktop
  • Operating system: Ubuntu Linux 18.04
  • Browser: Firefox 88.0b8 (64-bit)
@fullofcaffeine
Copy link
Member Author

A first hotfix attempt was made in this PR. It happened to not be an ideal solution, so it was discarded, but it triggered an interesting discussion on how to properly address it.

@fullofcaffeine
Copy link
Member Author

Had another try: #30649.

@priethor priethor added [Package] Components /packages/components [Package] Editor /packages/editor [Type] Bug An existing feature does not function as intended labels Apr 9, 2021
@fullofcaffeine fullofcaffeine changed the title User autocompleter enters an infinite matching loop, slows-down the editor User autocompleter keeps trying to match when it shouldn't, slows-down the editor Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Package] Editor /packages/editor [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants