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

Rename <Slate> component value prop to initialValue #5421

Merged
merged 4 commits into from
May 26, 2023

Conversation

e1himself
Copy link
Contributor

Description

The Slate editor is in fact an uncontrolled component, but the public API deceives into thinking it's a controlled input. This is because of the value and onChange is a common React convention for controlled inputs, while uncontrolled inputs use initialValue instead.

Issue
Fixes #4992

Example

Before:

<Slate editor={editor} value={value} />

After:

<Slate editor={editor} initialValue={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 May 12, 2023

🦋 Changeset detected

Latest commit: ec5d95d

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 Minor

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

@e1himself e1himself changed the title Change - Rename value prop to initialValue Rename <Slate> component value prop to initialValue May 12, 2023
@dylans
Copy link
Collaborator

dylans commented May 14, 2023

Looks good and makes sense to me. Going to leave it open for a couple of days in case anyone has other feedback.

@dylans dylans merged commit 91e388e into ianstormtaylor:main May 26, 2023
12 checks passed
@github-actions github-actions bot mentioned this pull request May 26, 2023
CalvinRodo added a commit to cds-snc/gc-articles that referenced this pull request Jul 4, 2023
CalvinRodo added a commit to cds-snc/gc-articles that referenced this pull request Jul 4, 2023
@atanasov-deyan
Copy link

apologies for jumping into an already merged PR, but wouldn't this be a breaking change, as the API is changing? This is not explicitly highlighted anywhere, tbh. wdyt?

@pchr-srf
Copy link

What @atanasov-deyan says, just spent more time than I care to admit on trying to find out why stuff wasn't working. Turns out a minor change only visible in https://github.com/ianstormtaylor/slate/blob/main/packages/slate-react/CHANGELOG.md#0950 was the culprit, fixed with a oneliner 🙈

@e1himself e1himself deleted the change/initial-value branch September 5, 2023 09:37
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.

value should be renamed to initialValue
4 participants