paper-tags-input icon indicating copy to clipboard operation
paper-tags-input copied to clipboard

enableAdd and enableRemove default to true

Open BootsSiR opened this issue 8 years ago • 8 comments

Which means you can't set them to false with markup. If you want to set them to false currently, you have to create Boolean properties and use those.

see: https://www.polymer-project.org/1.0/docs/devguide/properties#configuring-boolean-properties

BootsSiR avatar Feb 22 '17 20:02 BootsSiR

@BootsSiR

Did u test that you cannot set them to false with markup?

Because in the demo, it's using the markup to set it to false. Both enableAdd and enableRemove is working fine.

http://cheonhyangzhang.github.io/paper-tags-input/components/paper-tags-input/

cheonhyangzhang avatar Feb 22 '17 20:02 cheonhyangzhang

I did try it out yes. I was only able to get them to take effect by creating this property:

        properties: {
            booleanFalse: {
                type: Boolean,
                value: false
            }
        },

and using it in the markup:

<paper-tags-input size="small" tags="[[mytags]]" enable-add="[[booleanFalse]]" enable-remove="[[booleanFalse]]">

BootsSiR avatar Feb 22 '17 20:02 BootsSiR

Polymer 1.8.0 fyi

BootsSiR avatar Feb 22 '17 20:02 BootsSiR

@BootsSiR Got it. Yep. I just looked at the demo html, it's setting the variable in the app's property like this

var app = document.querySelector('#app');
app.enable_add = false;
app.enable_remove = false;

and then using it by

<paper-tags-input enable-add="{{enable_add}}" tags="{{testtags}}" 
    placeholder="Please enter a test tag for this" empty-error-message="Oops. Tag could not be empty" label="Remove only" >

Based on the doc you shared, https://www.polymer-project.org/1.0/docs/devguide/properties#configuring-boolean-properties I think it's trying to say there is no way to do sth like this

<paper-tags-input enable-add="{{false}}" tags="{{testtags}}" 
    placeholder="Please enter a test tag for this" empty-error-message="Oops. Tag could not be empty" label="Remove only" >

And this is not going to work with paper-tags-input current implementation. The only way to specify that to be false is to have a variable defined which is false.

But I don't think it's fine to change the default value to be false, because

  1. It makes more sense to have the default feature to enable add functionality and remove functionality.
  2. If we change the default value to be false, then it's going to affect all the pages that's currently using paper-tags-input which didn't specify a value for those two properties.

cheonhyangzhang avatar Feb 22 '17 22:02 cheonhyangzhang

Yeah, you don't really want to change existing behavior like that with people using the control (which is great btw). Maybe just make a note of this in the docs or something?

BootsSiR avatar Feb 22 '17 22:02 BootsSiR

Yep. That's true it's good to make a note of this so that people don't get confused about it. Will do that. Nice catch. Thanks ~

cheonhyangzhang avatar Feb 22 '17 23:02 cheonhyangzhang

I've noticed the way the Polymer team seems to handle this. If they had created this element they'd have had two properties like noAddFeature and noRemoveFeature both defaulting to false. That way the functionality is enabled by default, however if you want to disable the features, you can just include no-add-feature="true" and/or no-remove-feature="true" in markup. Just means you have to use reverse logic in the element's implementation.

anyways, just thought I'd share 👍

BootsSiR avatar Feb 24 '17 15:02 BootsSiR

Yep.

I didn't notice that when I implement the element.

Very nice catch.

cheonhyangzhang avatar Mar 06 '17 19:03 cheonhyangzhang