Comments (9)
Would be nice to have access to (e) from onChange e.g. onClick={(e) => onRemove(key)}
.
I want to do preventDefault for instance.
from react-tagsinput.
Sounds like a great idea, I will add it later today.
from react-tagsinput.
Awesome! I actually found a solution to the problem but i am cheating a bit so this solution would be better. For those using Redux-Form I will post my example below.
Then I am calling a function in the parent component to the form which changes the initial values of the form with the new tags and feeds them back down into this component. It does the job well enough, having extra arguments to show which indexes changed would still be ideal!
Thanks for this component, it's working well for email inputs! The Regex and paste splitting is especially convenient.
const EmailInputField = ({
fieldProps,
addOnPaste = true,
onlyUnique = true,
label = 'Name',
...props
}) => {
const { removeField } = fieldProps
const tagsProps = {
...props,
addOnPaste,
onlyUnique,
renderTag: ({tag, key, onRemove, ...other}) => (
<span key={key} {...other}>
{tag}
<a onClick={() => removeField(key)} />
</span>
),
pasteSplit: data => data.split(',').map(d => d.trim()),
validationRegex: /^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,
}
return (
<div>
<div className={styles.labelColumn}>
{label}
</div>
<div className={styles.fieldColumnTags}>
<Tags {...tagsProps} />
</div>
</div>
)
}
from react-tagsinput.
Thank you for the example @bradennapier , I'm glad that you like the component 😄
I have added in two more arguments to onChange
in version 3.6.2
, changed
an array of tags that have changed and changedIndexes
and array of indexes of the tags that have changed. Hope this will suit your needs.
from react-tagsinput.
Awesome, this is perfect! Much appreciated!
from react-tagsinput.
@olahol Isn't it a breaking change? I guess it should be released in a major version.
from react-tagsinput.
@diessica You think so? Is adding two extra arguments to onChange
breaking? I cant see it unless somebody passes this.setState
directly to onChange
.
from react-tagsinput.
Or if they were to use spread operators on arguments for some reason when only a single argument was present before. I wouldn't think this is breaking.
from react-tagsinput.
Can you share code for EmailInputField use in redux form Or what data give to fieldProps
from react-tagsinput.
Related Issues (20)
- AutoSuggest adding tag then text below HOT 1
- Please add the info for pasteSplit
- How do I add icon at the beginning of the component? HOT 3
- Mobile devices cannot add tags - enter does not submit tags but instead moves to next form field HOT 1
- dynamic width
- Can we add email validation so It only allow to enter email while making tags HOT 1
- Tag creation does not work on mobile HOT 1
- onpaste ? HOT 2
- How to switch the cursor among multiple tags
- How it works when pass empty array on start?
- render html instance
- peer dependency conflict with react 18.x HOT 4
- [Bug][3.20.0] Empty tag added on blur HOT 1
- Can't remove a tag when input filed has overflow HOT 2
- 'define' is not defined
- bug: validate functiob does not exists anymore but still displayed in the readme file
- Passing objects as tags does not work because of trimming HOT 3
- React native Text input native props are not working like onChange,onchageTExt and also value prop
- Why there are no id and name attributes?
- shift+enter not working and check event
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-tagsinput.