react-tagsinput icon indicating copy to clipboard operation
react-tagsinput copied to clipboard

preventSubmit prop not working

Open ad1992 opened this issue 8 years ago • 3 comments

@@ -286,7 +286,7 @@
         tags = tags.filter(function (tag) {
           var tagDisplayValue = _this2._getTagDisplayValue(tag);
           if (typeof tagDisplayValue.trim === 'function') {
-            return tagDisplayValue.trim().length > 0;
+            return tagDisplayValue.trim().length >= 0;
           } else {
             return tagDisplayValue;
           }
@@ -351,10 +351,10 @@
       value: function accept() {
         var tag = this._tag();

-        if (tag !== '') {
-          tag = this._makeTag(tag);
-          return this._addTags([tag]);
-        }
+
+        tag = this._makeTag(tag);
+        return this._addTags([tag]);
+

         return false;
       }

The preventSubmit prop is not working if set to false. By making the above hacky fix it works. I have provided the diff of the changed code.

ad1992 avatar May 11 '17 11:05 ad1992

It was my PR that introduced this prop - I still perhaps think the prop name isn't the best - however it was written to maintain the default behaviour (the props default setting is false). https://github.com/olahol/react-tagsinput/pull/135

Could you possibly describe the behaviour you're experiencing, there are also some tests backing this prop up if you could potentially add a failing one I'd be happy to try and take a look https://github.com/olahol/react-tagsinput/blob/master/test/index.js#L522

ryanhyslop avatar May 30 '17 10:05 ryanhyslop

@ryanhyslop Sorry for the delayed response. I have added a failing test and the fix. Can you please check https://github.com/olahol/react-tagsinput/pull/168 I agree that the prop name can be better something like allowEmptyTag ? what do you think ?

ad1992 avatar Feb 24 '18 12:02 ad1992

@ryanhyslop any updates ?

ad1992 avatar Mar 05 '18 13:03 ad1992