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 combobox targetRange for mention input #2752

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JannesMeyer
Copy link

Description

Fixes #1843
Fixes #2533

After investigating #1843 I discovered that Slate inserts an empty text node before the mention input to fulfil this normalization constraint:

  1. Inline nodes cannot be the first or last child of a parent block, nor can it be next to another inline node in the children array. If this is the case, an empty text node will be added to correct this to be in compliance with the constraint.

Source: https://docs.slatejs.org/concepts/11-normalizing

Is there any better way to wait for normalization without setTimeout()?

Copy link

changeset-bot bot commented Nov 19, 2023

🦋 Changeset detected

Latest commit: 3acfad9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@udecode/plate-mention Patch
@udecode/plate Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Nov 19, 2023

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

Name Status Preview Comments Updated (UTC)
plate ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 19, 2023 7:37pm

Copy link
Contributor

reviewpad bot commented Nov 19, 2023

Thank you @JannesMeyer for this first contribution!

@12joan
Copy link
Collaborator

12joan commented Nov 19, 2023

Thanks for the PR!

Is there any better way to wait for normalization without setTimeout()?

In the future, perhaps we could add a helper function to Plate core (or Slate core) that queues up a callback until the next time onChange gets called to signify the editor state is stable. For now, however, I think using setTimeout is the simplest approach.

@12joan 12joan requested a review from zbeyens November 19, 2023 19:39
@JannesMeyer
Copy link
Author

Thanks for the reply, @12joan :)

I just noticed the failing test which expects the combobox state to be updated immediately. I don't know how to resolve that yet, but I will try to think of a solution.

@zbeyens zbeyens marked this pull request as draft November 28, 2023 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
small Pull request is small
Projects
None yet
3 participants