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

Enable an option to have empty tags #420

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

sp2hari
Copy link
Contributor

@sp2hari sp2hari commented Oct 28, 2018

No description provided.

Copy link
Member

@ad1992 ad1992 left a 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

const $input = $el.find('.ReactTags__tagInputField');
$input.simulate('change', { target: { value: '' } });
$input.simulate('keyDown', { keyCode: ENTER_ARROW_KEY_CODE });
if (allowEmpty) {
Copy link
Member

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

@@ -234,7 +236,7 @@ class ReactTags extends Component {
? suggestions[selectedIndex]
: { id: query, [this.props.labelField]: query };

if (selectedQuery !== '') {
if (selectedQuery !== '' || this.props.allowEmpty === true) {
Copy link
Member

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

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) {
Copy link
Member

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([{
Copy link
Member

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.

@stale
Copy link

stale bot commented Dec 1, 2018

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.

@stale stale bot added the Stale label Dec 1, 2018
@ad1992 ad1992 added feature and removed Stale labels Dec 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants