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

CodeEditor component warns on missing onChange #6737

Closed
kmgalanakis opened this issue May 14, 2018 · 3 comments · Fixed by #6777
Closed

CodeEditor component warns on missing onChange #6737

kmgalanakis opened this issue May 14, 2018 · 3 comments · Fixed by #6777
Labels
[Feature] UI Components Impacts or related to the UI component system Good First Issue An issue that's suitable for someone looking to contribute for the first time [Type] Bug An existing feature does not function as intended

Comments

@kmgalanakis
Copy link

Coming from here https://wordpress.slack.com/archives/C02QB2JS7/p1526301453000491?thread_ts=1526050915.000297&cid=C02QB2JS7

When creating a post type with a template using the following code

function myplugin_register_lorem_post_type() {
    $args = array(
        'public' => true,
        'label'  => 'Lorems',
        'show_in_rest' => true,
        'template' => array(
            array( 'core/html', array(
                'content' => '<p>Hello</p>'
            ) ),
        ),
    );
    register_post_type( 'lorem', $args );
}
add_action( 'init', 'myplugin_register_lorem_post_type' );

I get the following console error

Warning: Failed prop type: You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.
    in textarea (created by CodeEditor)
    in CodeEditor (created by LazyCodeEditor)
    in LazyCodeEditor
    in div
    in Unknown (created by WithState(Component))
    in WithState(Component) (created by Edit)
    in Edit (created by WithToolbarControls(Edit))
    in WithToolbarControls(Edit) (created by WithInspectorControl(WithToolbarControls(Edit)))
    in WithInspectorControl(WithToolbarControls(Edit)) (created by WithInspectorControl(WithInspectorControl(WithToolbarControls(Edit))))
    in WithInspectorControl(WithInspectorControl(WithToolbarControls(Edit))) (created by modifyCustomHTMLBlock)
    in modifyCustomHTMLBlock
    in Unknown (created by WithDispatch(Component))
    in WithDispatch(Component) (created by WithUseOnceValidation(modifyCustomHTMLBlock))
    in WithUseOnceValidation(modifyCustomHTMLBlock) (created by WithFilters(Edit))
    in WithFilters(Edit) (created by BlockEdit)
    in BlockEdit (created by WrappedComponent)
    in WrappedComponent (created by WithApiData(WrappedComponent))
    in WithApiData(WrappedComponent) (created by WithSelect(WithApiData(WrappedComponent)))
    in WithSelect(WithApiData(WrappedComponent)) (created by BlockListBlock)
    in BlockCrashBoundary (created by BlockListBlock)
    in div (created by IgnoreNestedEvents)
    in IgnoreNestedEvents (created by BlockListBlock)
    in div (created by IgnoreNestedEvents)
    in IgnoreNestedEvents (created by BlockListBlock)
    in BlockListBlock (created by WithHoverAreasComponent)
    in WithHoverAreasComponent (created by (BlockListBlock))
    in (BlockListBlock) (created by WithAlign((BlockListBlock)))
    in WithAlign((BlockListBlock)) (created by WithFilters((BlockListBlock)))
    in WithFilters((BlockListBlock)) (created by WithViewportMatch(WithFilters((BlockListBlock))))
    in WithViewportMatch(WithFilters((BlockListBlock))) (created by WithDispatch(WithViewportMatch(WithFilters((BlockListBlock)))))
    in WithDispatch(WithViewportMatch(WithFilters((BlockListBlock)))) (created by WithSelect(WithDispatch(WithViewportMatch(WithFilters((BlockListBlock))))))
    in WithSelect(WithDispatch(WithViewportMatch(WithFilters((BlockListBlock))))) (created by BlockListLayout)
    in div (created by BlockListLayout)
    in BlockListLayout (created by WithDispatch(BlockListLayout))
    in WithDispatch(BlockListLayout) (created by WithSelect(WithDispatch(BlockListLayout)))
    in WithSelect(WithDispatch(BlockListLayout)) (created by WithSelect(WithSelect(WithDispatch(BlockListLayout))))
    in WithSelect(WithSelect(WithDispatch(BlockListLayout))) (created by BlockList)
    in BlockList (created by VisualEditor)
    in div (created by ObserveTyping)
    in ObserveTyping (created by WrappedComponent)
    in WrappedComponent (created by WithDispatch(WrappedComponent))
    in WithDispatch(WrappedComponent) (created by WithSelect(WithDispatch(WrappedComponent)))
    in WithSelect(WithDispatch(WrappedComponent)) (created by VisualEditor)
    in div (created by WritingFlow)
    in div (created by WritingFlow)
    in WritingFlow (created by WithDispatch(WritingFlow))
    in WithDispatch(WritingFlow) (created by WithSelect(WithDispatch(WritingFlow)))
    in WithSelect(WithDispatch(WritingFlow)) (created by VisualEditor)
    in div (created by BlockSelectionClearer)
    in BlockSelectionClearer (created by WithDispatch(BlockSelectionClearer))
    in WithDispatch(BlockSelectionClearer) (created by WithSelect(WithDispatch(BlockSelectionClearer)))
    in WithSelect(WithDispatch(BlockSelectionClearer)) (created by VisualEditor)
    in VisualEditor (created by Layout)
    in div (created by Layout)
    in div (created by Layout)
    in Layout (created by WithViewportMatch(Layout))
    in WithViewportMatch(Layout) (created by _class)
    in div (created by _class)
    in _class (created by WithDispatch(_class))
    in WithDispatch(_class) (created by WithSelect(WithDispatch(_class)))
    in WithSelect(WithDispatch(_class)) (created by Editor)
    in ErrorBoundary (created by Editor)
    in RichTextProvider (created by EditorProvider)
    in SlotFillProvider (created by EditorProvider)
    in APIProvider (created by EditorProvider)
    in DropZoneProvider (created by EditorProvider)
    in EditorProvider (created by WithDispatch(EditorProvider))
    in WithDispatch(EditorProvider) (created by Editor)
    in Editor (created by WithSelect(Editor))
    in WithSelect(Editor)
printWarning @ react-dom.cca5b42c.js:526
warning @ react-dom.cca5b42c.js:550
checkPropTypes @ react-dom.cca5b42c.js:2980
ReactControlledValuePropTypes.checkPropTypes @ react-dom.cca5b42c.js:3024
initWrapperState$2 @ react-dom.cca5b42c.js:13765
setInitialProperties$1 @ react-dom.cca5b42c.js:15540
finalizeInitialChildren @ react-dom.cca5b42c.js:16817
completeWork @ react-dom.cca5b42c.js:9823
completeUnitOfWork @ react-dom.cca5b42c.js:12117
performUnitOfWork @ react-dom.cca5b42c.js:12277
workLoop @ react-dom.cca5b42c.js:12289
renderRoot @ react-dom.cca5b42c.js:12320
performWorkOnRoot @ react-dom.cca5b42c.js:12895
performWork @ react-dom.cca5b42c.js:12816
performSyncWork @ react-dom.cca5b42c.js:12793
requestWork @ react-dom.cca5b42c.js:12693
scheduleWorkImpl @ react-dom.cca5b42c.js:12568
scheduleWork @ react-dom.cca5b42c.js:12528
enqueueSetState @ react-dom.cca5b42c.js:7090
Component.setState @ react.57836462.js:492
(anonymous) @ index.js:70
Promise.then (async)
componentDidMount @ index.js:68
commitLifeCycles @ react-dom.cca5b42c.js:10230
commitAllLifeCycles @ react-dom.cca5b42c.js:11901
callCallback @ react-dom.cca5b42c.js:140
invokeGuardedCallbackDev @ react-dom.cca5b42c.js:178
invokeGuardedCallback @ react-dom.cca5b42c.js:227
commitRoot @ react-dom.cca5b42c.js:12040
completeRoot @ react-dom.cca5b42c.js:12948
performWorkOnRoot @ react-dom.cca5b42c.js:12898
performWork @ react-dom.cca5b42c.js:12816
performSyncWork @ react-dom.cca5b42c.js:12793
requestWork @ react-dom.cca5b42c.js:12693
scheduleWorkImpl @ react-dom.cca5b42c.js:12568
scheduleWork @ react-dom.cca5b42c.js:12528
scheduleRootUpdate @ react-dom.cca5b42c.js:13156
updateContainerAtExpirationTime @ react-dom.cca5b42c.js:13184
updateContainer @ react-dom.cca5b42c.js:13211
ReactRoot.render @ react-dom.cca5b42c.js:16647
(anonymous) @ react-dom.cca5b42c.js:17066
unbatchedUpdates @ react-dom.cca5b42c.js:13003
legacyRenderSubtreeIntoContainer @ react-dom.cca5b42c.js:17062
render @ react-dom.cca5b42c.js:17121
initializeEditor @ index.js:90
(anonymous) @ post-new.php?post_type=lorem:3738
@aduth aduth changed the title Console error when creating a template for a post type CodeEditor component warns on missing onChange May 14, 2018
@aduth aduth added [Type] Bug An existing feature does not function as intended [Feature] UI Components Impacts or related to the UI component system Good First Issue An issue that's suitable for someone looking to contribute for the first time labels May 14, 2018
@vtrpldn
Copy link

vtrpldn commented May 15, 2018

Hey there!

Can you give me more details about the steps to reproduce this warning? I'd like to take a look at that and couldn't reproduce.

@kmgalanakis
Copy link
Author

@vtrpldn hey!

If you add this code inside your theme's function.php you will see that a new CPT is registered on your site, named Lorems.

Trying to add a new Lorem item, you will notice that once the page is fully loaded you will get the console error mentioned above.

Let me know if you need further info.

Thanks for talking a look.

@ajitbohra
Copy link
Member

#6777 will help fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] UI Components Impacts or related to the UI component system Good First Issue An issue that's suitable for someone looking to contribute for the first time [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants