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

Update the RichText documentation with an onSetup example #7224

Closed
wants to merge 1 commit into from

Conversation

notnownikki
Copy link
Member

Description

Added some documentation about the onSetup prop, and an example of how to use it to set the focus on a newly created editor.

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

Thanks for the addition, left a small comment.


*Optional.* Called when the editor has been setup.

If you want to use this to give focus to a new editor instance, you must wait until the editor has been rendered before calling `.focus` on it.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this common? I personally don't think so, I'd just use a more generic example here Something like:

function onSetup( editor ) {
  editor.on( 'focus', () => console.log( 'The editor has been focused' ) );
}

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know how common it will be... but if you're dealing with lists of items that have RichText components in them and you want to focus new ones, it is a gotcha. Perhaps that the focus event example in there, because that's an example more people are likely to use, and the note about focusing the editor afterwards?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think personally either of these two examples is common because in the last versions of Gutenberg we are trying to do this automatically (handle focus). I know it's not solved entirely for all use-cases. My concern is that people would assume the onSetup is only useful to handle focus (in both examples)

@aduth
Copy link
Member

aduth commented Sep 13, 2018

This prop has since been marked as unstable as intentionally undocumented.

See: #9106

@aduth aduth closed this Sep 13, 2018
@aduth aduth deleted the update/richtext-onsetup-docs branch September 13, 2018 19:02
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.

3 participants