-
-
Notifications
You must be signed in to change notification settings - Fork 387
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
Enable an option to have empty tags #420
base: master
Are you sure you want to change the base?
Conversation
623df98
to
f133752
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @sp2hari for contributing
__tests__/reactTags.test.js
Outdated
const $input = $el.find('.ReactTags__tagInputField'); | ||
$input.simulate('change', { target: { value: '' } }); | ||
$input.simulate('keyDown', { keyCode: ENTER_ARROW_KEY_CODE }); | ||
if (allowEmpty) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noooo lets not have if else conditions for assertions inside specs. This approach is fine when the assertions are exactly same. Please create two different specs
src/components/ReactTags.js
Outdated
@@ -234,7 +236,7 @@ class ReactTags extends Component { | |||
? suggestions[selectedIndex] | |||
: { id: query, [this.props.labelField]: query }; | |||
|
|||
if (selectedQuery !== '') { | |||
if (selectedQuery !== '' || this.props.allowEmpty === true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this.props.allowEmpty === true
, its anyways returning when allowEmpty
is false
src/components/ReactTags.js
Outdated
const { tags, labelField, allowUnique } = this.props; | ||
if (!tag.id || !tag[labelField]) { | ||
const { tags, labelField, allowUnique, allowEmpty } = this.props; | ||
if ( (!tag.id || !tag[labelField]) && allowEmpty === false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of doing &&
here can we do early return when !allowEmpty
?
const $input = $el.find('.ReactTags__tagInputField'); | ||
$input.simulate('change', { target: { value: '' } }); | ||
$input.simulate('keyDown', { keyCode: ENTER_ARROW_KEY_CODE }); | ||
expect(actual).not.to.have.deep.members([{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just checking the length of actual
is zero should be enough here.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
No description provided.