diff --git a/app/components/title-field.js b/app/components/title-field.js
index eb22784f..8d96ceec 100644
--- a/app/components/title-field.js
+++ b/app/components/title-field.js
@@ -1,4 +1,5 @@
import React, { Component } from 'react'
+import ReactDOM from 'react-dom'
import styled from 'styled-components'
import Icon from './icon'
import { Plain as PlainButton, Green as GreenButton } from './button'
@@ -35,32 +36,38 @@ const EditableFieldWrapper = styled.div`
}
`
-const InputField = styled.input`
+const InputFieldStyle = styled.input`
:focus {
outline: none;
}
`
+class InputField extends Component {
+ componentDidMount () {
+ const input = ReactDOM.findDOMNode(this)
+ input.focus()
+ input.select()
+ }
+ render () {
+ return
+ }
+}
+
class TitleField extends Component {
- startEditing () {
- this.setState({ editing: true })
+ constructor (props) {
+ super(props)
+ this.titleInput = React.createRef()
}
onclick (ev) {
ev.stopPropagation()
ev.preventDefault()
- this.startEditing()
-
- // setTimeout? Because ref on input is set asynchronously, and later. So we can't do focus, select on it until ref is set
- setTimeout(() => {
- this.titleInput.focus()
- this.titleInput.select()
- }, 0)
+ this.setState({ editing: true })
}
commit () {
const oldValue = this.props.value
- const newValue = this.titleInput.value
+ const newValue = ReactDOM.findDOMNode(this.titleInput.current).value
if (oldValue !== newValue) {
this.props.onChange(newValue)
}
@@ -108,14 +115,12 @@ class TitleField extends Component {
className='bn f6 pl1 normal w-100'
defaultValue={value}
onKeyUp={ev => this.handleKeyup(ev)}
- innerRef={input => {
- this.titleInput = input
- }}
+ ref={this.titleInput}
/>
- {!modified ? (
- this.commit()}>Save
- ) : (
+ {modified ? (
this.commit()}>Save
+ ) : (
+ this.cancel()}>Save
)}
diff --git a/app/containers/drag-drop.js b/app/containers/drag-drop.js
index 17116be8..f2f8970e 100644
--- a/app/containers/drag-drop.js
+++ b/app/containers/drag-drop.js
@@ -34,10 +34,14 @@ const DropIcon = styled(Icon)`
color: white;
`
-const DragDropContainer = connect(mapStateToProps, mapDispatchToProps)(function(props){
- return
-
-
+const DragDropContainer = connect(mapStateToProps, mapDispatchToProps)(function (
+ props
+) {
+ return (
+
+
+
+ )
})
export default DragDropContainer