Skip to content

Commit

Permalink
Fix reuse modal
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Nov 10, 2024
1 parent 6c5e2f3 commit e4d35a3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions rdmo/projects/assets/js/interview/components/main/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import ProjectApi from '../../api/ProjectApi'
import ValueApi from '../../api/ValueApi'

const Search = ({ attribute, values, setValues, collection = false }) => {
// create a key for the first AsyncSelect, to reset the loaded values when project or snapshot changes
const key = (values.project ? values.project.id : '') + (values.snapshot ? '-all' : '')

const handleLoadValues = useDebouncedCallback((search, callback) => {
ValueApi.searchValues({
Expand Down Expand Up @@ -53,7 +55,7 @@ const Search = ({ attribute, values, setValues, collection = false }) => {

return <>
<AsyncSelect
key={JSON.stringify(values.project)}
key={key}
classNamePrefix="react-select"
className='react-select'
placeholder={gettext('Search for project or snapshot title, or answer text ...')}
Expand Down Expand Up @@ -113,7 +115,10 @@ const Search = ({ attribute, values, setValues, collection = false }) => {
<input
type="checkbox"
checked={values.snapshot}
onChange={() => setValues({ ...values, snapshot: !values.snapshot })}
onChange={() => setValues({
...values,
value: values.snapshot ? '' : values.value, // reset value
snapshot: !values.snapshot })}
/>
<span>{gettext('Include snapshots in the search')}</span>
</label>
Expand Down

0 comments on commit e4d35a3

Please sign in to comment.