feat: clear inputs onSubmit

This commit is contained in:
ysandler 2020-07-30 22:01:10 -05:00 committed by Joshua Shoemaker
parent 714fd6357e
commit 87fce3c636
3 changed files with 24 additions and 0 deletions

View File

@ -30,6 +30,11 @@ class CreateNodule extends Component {
document.addEventListener('updateTables', this.updateTableList)
}
clearInput = () => {
this.setState({ noduleType: '' })
this.tableSelect.current.clearTablesSelected()
}
handleChange = (e, value) => {
this.setState({ noduleType: value.value })
}
@ -65,6 +70,8 @@ class CreateNodule extends Component {
structure: structureProperties
})
}
this.clearInput()
}
updateTableList = () => {
@ -94,6 +101,7 @@ class CreateNodule extends Component {
<br />
<Dropdown
value ={this.state.noduleType}
placeholder='Select a Nodule Type'
options={[
{key: 'Join Nodule', text: 'Join Nodule', value: 'join', icon: 'sitemap'},

View File

@ -15,6 +15,10 @@ class TableSelect extends Component {
document.addEventListener('updateTables', this.updateTableList)
}
clearTablesSelected = () => {
this.setState({ selectedTablesLabels: [] })
}
getSelectedTableLabels = () => this.state.selectedTablesLabels
toggleSelect = label => {

View File

@ -12,12 +12,24 @@ class CreateTableForm extends Component {
this.tableFileInput = React.createRef()
}
// handleLabelChange = (e, value) => {
// e.preventDefault()
// this.setState({ label: value })
// }
// handleFileChange = (e, value) => {
// e.preventDefault()
// this.setState({ file: value })
// }
handleSubmit = async e => {
e.preventDefault()
const label = this.tableLabelInput.current.inputRef.current.value
const file = this.tableFileInput.current.inputRef.current.files[0]
this.controller.submitLocalFile({ label, file })
this.tableLabelInput.current.inputRef.current.value = ''
}
render = () => {