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

Issue 5782 #5783

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

ianleeduckworth
Copy link

Description
Fixes issue where instructions for renderProps in the react-slate documentation, if followed properly, produce an undesirable effect. This PR updates instructions such that a user can re-style the placeholder while still maintaining desirable default behavior

Issue
Fixes: #5782

Example

<Editable
  placeholder="Enter text here..."
  renderPlaceholder={({ attributes, children }) => {
    const styledAttributes = {
      ...attributes,
      style: {
        ...attributes.style,
        color: 'gray',
      },
    };
    return <div {...styledAttributes}>{children}</div>;
  }}
/>

Context
It was noticed that, when following the docs exactly, for renderProps within react-slate that the placeholder was behaving strangely. It was then noticed that in the docs the style prop that came in from attributes was being completely overridden. This was creating a situation where the placeholder exhibited some strange and undesirable behavior. The documentation has been updated so that the attributes prop that comes in is extended upon instead of overwritten entirely. This allows a user to do things like change the color, opacity, etc without overwriting critical style related props.

Checks
No checks necessary; only a documentation change

…sired effect if the instructions are followed
Copy link

changeset-bot bot commented Dec 22, 2024

⚠️ No Changeset found

Latest commit: 87a8450

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Collaborator

@dylans dylans left a comment

Choose a reason for hiding this comment

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

@ianleeduckworth any chance you could run prettier on this real quick and then I'll land it? Thanks!

Copy link
Collaborator

@dylans dylans left a comment

Choose a reason for hiding this comment

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

These are the two changes needed to make this pass.

docs/libraries/slate-react/editable.md Outdated Show resolved Hide resolved
docs/libraries/slate-react/editable.md Outdated Show resolved Hide resolved
fix incorrect code format label
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.

Error with documentation regarding how to use renderPlaceholder
2 participants