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

Add onSelectionChange and onValueChange in Slate React component #5526

Merged
merged 5 commits into from
Oct 20, 2023

Conversation

jkcs
Copy link
Contributor

@jkcs jkcs commented Oct 19, 2023

Description
Add onSelectionChange and onValueChange in Slate React component

Issue
Fixes: #5521
/claim udecode/plate#2700

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.)

Copy link
Contributor

@zbeyens zbeyens left a comment

Choose a reason for hiding this comment

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

Great PR, I've added a few suggestions then it should be complete

packages/slate-react/src/components/slate.tsx Outdated Show resolved Hide resolved
packages/slate-react/test/index.spec.tsx Show resolved Hide resolved
})
await act(async () => Transforms.insertText(editor, 'Hello word!'))
expect(onValueChange).toHaveBeenCalled()
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add

expect(onChange).toHaveBeenCalled()
expect(onSelectionChange).toHaveBeenCalled()

And another test using Transforms.setNodes that should not change selection?

Copy link
Contributor Author

@jkcs jkcs Oct 20, 2023

Choose a reason for hiding this comment

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

I added a unit test case using Transforms.setNodes to set the text as bold. Is that okay?

@jkcs
Copy link
Contributor Author

jkcs commented Oct 20, 2023

Great PR, I've added a few suggestions then it should be complete

Thank you for your suggestion. I will make the changes as soon as possible

@jkcs jkcs changed the title Add onSelectorChange and onValueChange in Slate React component Add onSelectionChange and onValueChange in Slate React component Oct 20, 2023
Copy link
Contributor

@zbeyens zbeyens left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@dylans dylans merged commit 623f445 into ianstormtaylor:main Oct 20, 2023
11 checks passed
This was referenced Oct 20, 2023
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.

Derive onSelectionChange and onValueChange from onChange
3 participants