From a1e0223b207cbfc487e9ae17aa44325f01737118 Mon Sep 17 00:00:00 2001 From: feruz <fmiboy@gmail.com> Date: Fri, 10 Jan 2020 07:04:24 +0200 Subject: [PATCH] handleIsValid removal, Form validity check for tags and title length --- .../editorElements/tagInput/view/tagInputView.js | 12 ++---------- src/screens/editor/screen/editorScreen.js | 4 +++- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/components/editorElements/tagInput/view/tagInputView.js b/src/components/editorElements/tagInput/view/tagInputView.js index d6cf6d1e6..02543ace8 100644 --- a/src/components/editorElements/tagInput/view/tagInputView.js +++ b/src/components/editorElements/tagInput/view/tagInputView.js @@ -12,7 +12,6 @@ import globalStyles from '../../../../globalStyles'; const TagInput = ({ value, onChange, - handleIsValid, componentID, handleTagChanged, intl, @@ -57,14 +56,11 @@ const TagInput = ({ handleTagChanged([...cats]); } - - if (handleIsValid) { - handleIsValid(componentID, !!(_text && _text.length)); - } }; const _handleOnBlur = () => { + let cats = []; if (onChange) { - let cats = text.trim().split(' '); + cats = text.trim().split(' '); if (handleTagChanged && cats.length > 0) { cats.length > 10 ? (setWarning(intl.formatMessage({ id: 'editor.limited_tags' })), setHeight(60)) @@ -87,10 +83,6 @@ const TagInput = ({ } onChange(text); } - - if (handleIsValid) { - handleIsValid(componentID, !!(text && text.length)); - } }; return ( <View style={[globalStyles.containerHorizontal16, { height: Math.max(35, height) }]}> diff --git a/src/screens/editor/screen/editorScreen.js b/src/screens/editor/screen/editorScreen.js index 7cb61e954..2fa607844 100644 --- a/src/screens/editor/screen/editorScreen.js +++ b/src/screens/editor/screen/editorScreen.js @@ -131,8 +131,10 @@ class EditorScreen extends Component { } else { isFormValid = get(fields, 'title', '') && + get(fields, 'title', '').length < 255 && (get(fields, 'body', '') || (bodyText && bodyText > 0)) && - get(fields, 'tags', null); + get(fields, 'tags', null) && + get(fields, 'tags', null).length < 10; } this.setState({ isFormValid });