Flag for onChange prop to tell if it was called by `_addTag` or `_removeTag`
ilias-t opened this issue · comments
Just a suggestion, in order to distinguish between when a tag was added vs when one was removed, I would suggest passing in a fourth parameter (type boolean
) to the onChange
prop that is true
when called by _addTag
and false
when called by _removeTag
. If ppl think it's a decent idea happy to make a PR.
I think this already possible by checking if oldValue.length < value.length
in the handling of onChange
but I will consider adding it if it is wanted.
Thank you for your work on react-tagsinput @olahol (also the contributors). I checked the documentation to find something like the proposed solution but in the end found your comment working (I would eventually do that but I thought there would be an in-component use for such a thing.
Having an action provided to onChange as the fourth argument with either add
or remove
(or just a boolean true if it is an insert, false for remove) would make it better but if you think this is unneccessary, shall we maybe include your solution on the docs so that people would use it immediately?
I am also happy to make a PR if you are interested in updating the FAQ section