paper-tags-input
paper-tags-input copied to clipboard
enableAdd and enableRemove default to true
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
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/
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]]">
Polymer 1.8.0 fyi
@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
- It makes more sense to have the default feature to enable add functionality and remove functionality.
- 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.
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?
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 ~
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 👍
Yep.
I didn't notice that when I implement the element.
Very nice catch.