Skip to content

Export defaultScrollSelectionIntoView#5914

Merged
dylans merged 1 commit intoianstormtaylor:mainfrom
12joan:feat/export-defaultScrollSelectionIntoView
Jul 10, 2025
Merged

Export defaultScrollSelectionIntoView#5914
dylans merged 1 commit intoianstormtaylor:mainfrom
12joan:feat/export-defaultScrollSelectionIntoView

Conversation

@12joan
Copy link
Contributor

@12joan 12joan commented Jul 6, 2025

Description
Exports defaultScrollSelectionIntoView from slate-react, making it easier to extend rather than replace the default scrollSelectionIntoView behaviour.

Example

const SCROLLING = new WeakMap<Editor, boolean | undefined>()

// Custom scroll handler
const scrollSelectionIntoView = (editor: ReactEditor, domRange: DOMRange) => {
  if (SCROLLING.get(editor) ?? true) {
    defaultScrollSelectionIntoView(editor, domRange)
  }
}

const withoutScrolling = (editor: Editor, fn: () => void) => {
  const value = SCROLLING.get(editor) ?? true
  SCROLLING.set(editor, false)
  try {
    fn()
  } finally {
    SCROLLING.set(editor, value)
  }
}

Checks

  • The new code matches the existing patterns and styles.
  • The tests pass with yarn test.
  • The linter passes with yarn lint. (Fix errors with yarn fix.)
  • The relevant examples still work. (Run examples with yarn start.)
  • You've added a changeset if changing functionality. (Add one with yarn changeset add.)

@changeset-bot
Copy link

changeset-bot bot commented Jul 6, 2025

🦋 Changeset detected

Latest commit: 6345bf5

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

This PR includes changesets to release 1 package
Name Type
slate-react 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

@dylans dylans merged commit ef76eb4 into ianstormtaylor:main Jul 10, 2025
11 checks passed
@github-actions github-actions bot mentioned this pull request Jul 10, 2025
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

Successfully merging this pull request may close these issues.

2 participants