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: when compositionend after InlineEmbed element, selection do not update #4067

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 8 additions & 6 deletions packages/quill/src/blots/embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,18 @@ class Embed extends EmbedBlot {
}

update(mutations: MutationRecord[], context: Record<string, unknown>) {
mutations.forEach((mutation) => {
if (
const mutation = mutations.find((mutation) => {
return (
mutation.type === 'characterData' &&
(mutation.target === this.leftGuard ||
mutation.target === this.rightGuard)
) {
const range = this.restore(mutation.target as Text);
if (range) context.range = range;
}
);
});

if (mutation) {
const range = this.restore(mutation.target as Text);
Copy link
Author

Choose a reason for hiding this comment

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

here is what this.restore does:

  • get text from mutation.target.data,
  • calculate range by text
  • reset mutation.target.data to empty

so only the first execution of this.restore is effective
the next execution will get empty text from mutation.target.data, and return wrong range, which is the cause of the issue #4046

if (range) context.range = range;
}
}
}

Expand Down