Validation issues on RichTextInput
What you were expecting: No errors during validation on the RichTextInput
What happened instead:
Error:
index.js:2178 Warning: Failed prop type: Invalid prop error of type string supplied to FormControl, expected boolean.
in FormControl (created by WithStyles(FormControl))
in WithStyles(FormControl) (at RichTextInput/index.js:68)
in RichTextInput (created by WithStyles(RichTextInput))
in WithStyles(RichTextInput) (created by ConnectedField)
in ConnectedField (created by Connect(ConnectedField))
in Connect(ConnectedField) (created by Field)
in Field (created by FormFieldView)
in FormFieldView (created by DefaultValue)
in DefaultValue (created by Connect(DefaultValue))
in Connect(DefaultValue) (created by WithFormField)
in WithFormField (at TodosList.jsx:207)
in div (created by Labeled)
in div (created by FormControl)
in FormControl (created by WithStyles(FormControl))
in WithStyles(FormControl) (created by Labeled)
in Labeled (created by WithStyles(Labeled))
in WithStyles(Labeled) (created by FormInput)
in div (created by FormInput)
in FormInput (created by WithStyles(FormInput))
in WithStyles(FormInput) (created by FormTab)
in span (created by FormTab)
in FormTab (created by translate(FormTab))
in translate(FormTab) (at TodosList.jsx:206)
in Route (created by TabbedForm)
in div (created by CardContent)
in CardContent (created by WithStyles(CardContent))
in WithStyles(CardContent) (created by CardContentInner)
in CardContentInner (created by WithStyles(CardContentInner))
in WithStyles(CardContentInner) (created by TabbedForm)
in form (created by TabbedForm)
in TabbedForm (created by WithStyles(TabbedForm))
in WithStyles(TabbedForm) (created by Form(WithStyles(TabbedForm)))
in Form(WithStyles(TabbedForm)) (created by Connect(Form(WithStyles(TabbedForm))))
in Connect(Form(WithStyles(TabbedForm))) (created by ReduxForm)
in ReduxForm (created by translate(ReduxForm))
in translate(ReduxForm) (created by Connect(translate(ReduxForm)))
in Connect(translate(ReduxForm)) (created by Route)
in Route (created by withRouter(Connect(translate(ReduxForm))))
in withRouter(Connect(translate(ReduxForm))) (at TodosList.jsx:181)
in div (created by Paper)
in Paper (created by WithStyles(Paper))
in WithStyles(Paper) (created by Card)
in Card (created by WithStyles(Card))
in WithStyles(Card) (created by CreateView)
in div (created by CreateView)
in CreateView (created by CreateController)
in CreateController (created by translate(CreateController))
in translate(CreateController) (created by Connect(translate(CreateController)))
in Connect(translate(CreateController)) (created by Create)
in Create (at TodosList.jsx:180)
in Unknown (created by WithStyles(Component))
in WithStyles(Component) (created by WithPermissions)
in WithPermissions (created by Connect(WithPermissions))
in Connect(WithPermissions) (created by getContext(Connect(WithPermissions)))
in getContext(Connect(WithPermissions)) (created by Route)
in Route (created by Resource)
in Switch (created by Resource)
in Resource (created by Connect(Resource))
in Connect(Resource) (at App.js:21)
in Route (created by RoutesWithLayout)
in Switch (created by RoutesWithLayout)
in RoutesWithLayout (created by Route)
in div (created by Layout)
in main (created by Layout)
in div (created by Layout)
in div (created by Layout)
in Layout (created by WithStyles(Layout))
in WithStyles(Layout) (created by Route)
in Route (created by withRouter(WithStyles(Layout)))
in withRouter(WithStyles(Layout)) (created by Connect(withRouter(WithStyles(Layout))))
in Connect(withRouter(WithStyles(Layout))) (created by LayoutWithTheme)
in MuiThemeProvider (created by LayoutWithTheme)
in LayoutWithTheme (created by Route)
in Route (created by CoreAdminRouter)
in Switch (created by CoreAdminRouter)
in div (created by CoreAdminRouter)
in CoreAdminRouter (created by Connect(CoreAdminRouter))
in Connect(CoreAdminRouter) (created by getContext(Connect(CoreAdminRouter)))
in getContext(Connect(CoreAdminRouter)) (created by Route)
in Route (created by CoreAdmin)
in Switch (created by CoreAdmin)
in Router (created by ConnectedRouter)
in ConnectedRouter (created by CoreAdmin)
in TranslationProvider (created by withContext(TranslationProvider))
in withContext(TranslationProvider) (created by Connect(withContext(TranslationProvider)))
in Connect(withContext(TranslationProvider)) (created by CoreAdmin)
in Provider (created by CoreAdmin)
in CoreAdmin (created by withContext(CoreAdmin))
in withContext(CoreAdmin) (at App.js:15)
in App (at src/index.js:7)
Related code:
const validateDescription = [required('Description is required!')];
...
<FormTab label="Omschrijving">
<RichTextInput label="" source="description" fullWidth={true} validate={validateDescription} />
</FormTab>
After some research i found out that FormControl error needs a boolean and it get a string (the error message)
This issue can be fixed by changing
error={error} into error={error !== null && error !== undefined} on line 69 in the index.js file of the ra-input-rich-text package.
Environment
- React-admin version: 2.3.2
- React version: 16.5.2
- Browser: chrome
I could create a pr for this, however, since i have zero experience in setting up unit tests for react components and there are currently no tests for this component to use as a base, i have no idea how to set up a test (my experience with react is very limited) :-( Will this pr be accepted without a test or can someone give me advice on where to start to create a test? Also, the documentation needs to be updated to use validate instead of validation attribute. I could do this too.
I created a fork & fixed this issue on it, however, when i try to test it quil throws an error on line 44: this.quill.setContents(this.quill.clipboard.convert(value)); I could create a pull request if no unit test is needed, if it is needed, i would really appreciate some advice on how to mock/test. You can find the file with the fix on the following url: https://github.com/TomJannes/react-admin/blob/master/packages/ra-input-rich-text/src/index.js
I'm OK for a fix without unit test. Feel free to open a PR!
What's wrong with #1916?
The error property expects a boolean and receives the error string which throws the error in my original post. Will create a pr as fast as soon as possible.
Fixed by #2423