olahol / react-tagsinput

Highly customizable React component for inputing tags.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

any chance for the tags to be editable?

paigeflourin opened this issue · comments

i need this feature in my application

I am facing the same issue.

commented

Already got asked for in #137 & #184

I rewrite renderTag as follows, hope it helps

renderTag = (props) => {
	const { isTagFocus } = this.state
	const { tag, key, diasbled, onRemove, classNameRemove, getTagDisplayValue, ...other } = props
	return <span key={key} {...other} onBlur={() => { this.setState({ isTagFocus: false }) }}>
		{isTagFocus
			? <AutosizeInput
				onChange={this.hangdleTagChange}
				onFocus={(e) => {
					this.setState({
						tagEditIndex: this.state.inputBills.indexOf(e.target.value)
					})
				}}
				value={getTagDisplayValue(tag)}
				inputClassName={styles.tagEditInput}
			/>
			: <span onClick={() => { this.setState({ isTagFocus: true }) }}>
				{getTagDisplayValue(tag)}
			</span>
			}
			{!diasbled && <a className={classNameRemove} onClick={(e) => { onRemove(key) }}></a>}
	</span>
}

and how do you implement this?

Simply add the renderTag prop like so
<TagsInput renderTag={this.renderTag}/>