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

[form-builder] Wrap BlockEditor in forwardRef #1464

Merged
merged 1 commit into from
Aug 27, 2019

Conversation

bjoerge
Copy link
Member

@bjoerge bjoerge commented Aug 27, 2019

The change in #1450 wrapped the Block/Portable Text editor in a function component. Since function components can't be given refs, this caused the form builder to fail when trying to set focus on the portable text input component (see #1456).

I'm afraid we're going to see a lot more of these errors going forward, since the whole React community is shifting towards function components. So we should probably reconsider how we do the focus management in the form-builder (and align with the recent work/proposal to add declarative focus management to React).

I'll see if I can whip up a separate PR improving the error message to hint about this particular case, but this should at least fix the issue at hand.

The change in #1450 wrapped the Block/Portable Text editor in a function component. Since function components can't be given refs, this caused the input component to fail when trying to set focus on the portable text input component (see #1456).

I'm afraid we're going to see a lot more of these errors going forward, since the whole React community is shifting towards function components. So we should probably reconsider how we do the focus management in the form-builder (and align with the recent work/proposal to add declarative focus management to React).

I'll see if I can whip up a separate PR improving the error message to hint about this particular case, but this should fix the issue at hand.
Copy link
Member

@skogsmaskin skogsmaskin left a comment

Choose a reason for hiding this comment

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

Good catch!

@bjoerge bjoerge merged commit aff5e5c into next Aug 27, 2019
@bjoerge bjoerge deleted the forward-ref-to-block-editor branch August 27, 2019 09:26
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