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

Bug: Appears to be typo/bug in Playground autocomplete plugin #4589

Closed
msdrigg opened this issue Jun 1, 2023 · 2 comments · Fixed by #4592
Closed

Bug: Appears to be typo/bug in Playground autocomplete plugin #4589

msdrigg opened this issue Jun 1, 2023 · 2 comments · Fixed by #4592
Labels
all-platforms-bug other Feature not covered by the rest of the labels

Comments

@msdrigg
Copy link
Contributor

msdrigg commented Jun 1, 2023

On this line, it seems that

export class AutocompleteNode extends DecoratorNode<JSX.Element | null> {
  // TODO add comment
  __uuid: string;

  static clone(node: AutocompleteNode): AutocompleteNode {
    return new AutocompleteNode(node.__key);
  }

  constructor(uuid: string, key?: NodeKey) {
      super(key);
      this.__uuid = uuid;
  }

should be changed to

export class AutocompleteNode extends DecoratorNode<JSX.Element | null> {
  // TODO add comment
  __uuid: string;

  static clone(node: AutocompleteNode): AutocompleteNode {
-    return new AutocompleteNode(node.__key);
+    return new AutocompleteNode(node.__uuid);
  }
  constructor(uuid: string, key?: NodeKey) {
      super(key);
      this.__uuid = uuid;
  }

Lexical version: 11.1

The current behavior

Currently upon cloning, the uuid will change (see that the node key is used instead).

The UUID is meant to prevent multiple autocomplete options in the same view, but if the uuid can change, this functionality doesn't work. I noticed this when creating a modified autocomplete plugin based off this one. After changing selection, there could be several nodes working independently trying to update the editor concurrently.

The expected behavior

The UUID should be stable across all instances of the plugin and all nodes tracked by the plugin. This way the autocomplete node transform can clean up old ones.

Questions

Should I ping the original author? I may be misunderstanding the intended behavior here

@zurfyx
Copy link
Member

zurfyx commented Jun 2, 2023

Thanks, that's correct! Want to put a PR for it? Should match the constructor

constructor(uuid: string, key?: NodeKey)

So for the cloning bit you want to pass both params

@zurfyx zurfyx added all-platforms-bug typeahead other Feature not covered by the rest of the labels and removed typeahead labels Jun 2, 2023
@msdrigg
Copy link
Contributor Author

msdrigg commented Jun 2, 2023

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
all-platforms-bug other Feature not covered by the rest of the labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants