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

fix: Single anchor element per LexicalTypeaheadMenuPlugin instance #2768

Merged

Conversation

Morphyish
Copy link
Contributor

Fixes #2755

Creating the anchorElement in the Plugin itself and passing it down to the ShortcutTypeahead avoid creating a lot of unnecessary nodes that are never removed.

Every plugin that relies on LexicalTypeaheadMenuPlugin will get its anchor element that will then be properly updated with the new position, as it should.

Please note that I had to remove the startTransition when setting the resolution to null.
The transition was causing the / menu to flicker, but not the mentions. I'm not sure if it's a specific implementation issue in either of those playground plugins, but as hiding the menu should not cause any unnecessary loading state on the UI, it felt safe to remove.

Demo

Lexical.Playground.-.Google.Chrome.2022-08-05.11-31-58_Trim.mp4

@vercel
Copy link

vercel bot commented Aug 5, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
lexical ✅ Ready (Inspect) Visit Preview Aug 5, 2022 at 4:43PM (UTC)
lexical-playground ✅ Ready (Inspect) Visit Preview Aug 5, 2022 at 4:43PM (UTC)

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 5, 2022
Copy link
Contributor

@thegreatercurve thegreatercurve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution @Morphyish! One small fix, but I'll let @tylerjbainbridge review this fully as this was his component.

packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx Outdated Show resolved Hide resolved
- Move useEffect hook to position anchorElement to LexicalTypeaheadMenuPlugin
- Replace anchorElementRef prop with anchorElement
Copy link
Contributor

@tylerjbainbridge tylerjbainbridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me, good idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: LexicalTypeaheadMenuPlugin never cleans up its anchor element
4 participants