1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-18 04:01:45 +00:00

modify: add button for tag component

This commit is contained in:
sota1235
2016-12-21 17:44:23 +09:00
parent aac5cbf53e
commit 6550af698a

View File

@@ -8,7 +8,8 @@ class TagSelect extends React.Component {
super(props) super(props)
this.state = { this.state = {
newTag: '' newTag: '',
inputReady: false,
} }
} }
@@ -76,6 +77,7 @@ class TagSelect extends React.Component {
newTag: '' newTag: ''
}, () => { }, () => {
this.value = value this.value = value
this.setState({ inputReady: false })
this.props.onChange() this.props.onChange()
}) })
} }
@@ -98,6 +100,12 @@ class TagSelect extends React.Component {
} }
} }
handleNewTagInputReady (e) {
this.setState({
inputReady: true,
})
}
render () { render () {
let { value, className } = this.props let { value, className } = this.props
@@ -126,6 +134,9 @@ class TagSelect extends React.Component {
styleName='root' styleName='root'
> >
{tagList} {tagList}
{(() => {
if (this.state.inputReady) {
return (
<input styleName='newTag' <input styleName='newTag'
ref='newTag' ref='newTag'
value={this.state.newTag} value={this.state.newTag}
@@ -133,7 +144,17 @@ class TagSelect extends React.Component {
onChange={(e) => this.handleNewTagInputChange(e)} onChange={(e) => this.handleNewTagInputChange(e)}
onKeyDown={(e) => this.handleNewTagInputKeyDown(e)} onKeyDown={(e) => this.handleNewTagInputKeyDown(e)}
/> />
)
}
return (
<button styleName='add-tag-button'
onClick={(e) => this.handleNewTagInputReady(e)}
>
<i className='fa fa-plus' />
</button>
)
})()}
</div> </div>
) )
} }