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

scrollToSelection incorrectly identifies startDOM #1503

Closed
vilius opened this issue Jan 22, 2025 · 2 comments
Closed

scrollToSelection incorrectly identifies startDOM #1503

vilius opened this issue Jan 22, 2025 · 2 comments

Comments

@vilius
Copy link

vilius commented Jan 22, 2025

scrollToSelection() {
  let startDOM = this.domSelectionRange().focusNode!
  // ...
}

Context

  1. Two ProseMirror editor instances on the same page.
  2. Instance A and B.
  3. Your cursor is on instance B.
  4. If instance A calls scrollToSelection

Expected
Instance A DOM node is scrolled to selection

Actual
Instance B DOM node is scrolled to selection

Problem
domSelectionRange().focusNode! resolves to Instance A even if it was called from Instance B.

Proposed Solution
Check if resolved startDOM matches current instance. If not result in noop.

@marijnh
Copy link
Member

marijnh commented Jan 22, 2025

Indeed, that doesn't look right. Attached patch adds a check.

@vilius
Copy link
Author

vilius commented Jan 22, 2025

Indeed, that doesn't look right. Attached patch adds a check.

I'm very impressed by 30 minutes turnaround from filling an issue and a fix landing on master, mind blowing 🤯

Thanks, Marjin!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants