Commit 914829ed authored by Hugo Kerstens's avatar Hugo Kerstens

Update current submission after editing a student

parent 5f8b29f2
......@@ -144,6 +144,7 @@ class CheckStudents extends React.Component {
editActive: !this.state.editActive,
editStud: null
})
this.props.updateSubmission(this.state.index)
}
}
......@@ -164,7 +165,7 @@ class CheckStudents extends React.Component {
<div className='column is-one-quarter-desktop is-one-third-tablet'>
{this.state.editActive
? <EditPanel toggleEdit={this.toggleEdit} editStud={this.state.editStud} />
: <SearchPanel matchStudent={this.matchStudent} toggleEdit={this.toggleEdit}
: <SearchPanel matchStudent={this.matchStudent} toggleEdit={this.toggleEdit} submission={subm}
student={subm && subm.student} validated={subm && subm.validated} subIndex={this.state.index} />
}
</div>
......
......@@ -40,6 +40,25 @@ class SearchPanel extends React.Component {
componentDidUpdate (prevProps, prevState) {
this.searchInput.current.focus()
// Check if the search input is empty
if (!this.searchInput.current || !this.searchInput.current.value || this.searchInput.current.value.length === 0) {
if (this.props.submission && this.props.submission.student) {
// There is no result yet, always update it
if (this.state.result.length === 0) {
this.setState({
result: [this.props.submission.student]
})
// There is a result already, check if it is outdated
} else if (this.state.result.length === 1) {
const newResult = this.props.submission.student ? [this.props.submission.student] : []
if (this.state.result[0] !== newResult[0]) {
this.setState({
result: newResult
})
}
}
}
}
}
search = (event) => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment