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

View File

@ -12,12 +12,24 @@ class CreateTableForm extends Component {
this.tableFileInput = React.createRef() 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 => { handleSubmit = async e => {
e.preventDefault() e.preventDefault()
const label = this.tableLabelInput.current.inputRef.current.value const label = this.tableLabelInput.current.inputRef.current.value
const file = this.tableFileInput.current.inputRef.current.files[0] const file = this.tableFileInput.current.inputRef.current.files[0]
this.controller.submitLocalFile({ label, file }) this.controller.submitLocalFile({ label, file })
this.tableLabelInput.current.inputRef.current.value = ''
} }
render = () => { render = () => {