Skip to content

Commit

Permalink
[JN-1068] autofill does not overwrite values (#919)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorlbark authored Jun 3, 2024
1 parent 291831a commit bf74aa7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ui-core/src/components/forms/SurveyAutoCompleteButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { SurveyModel } from 'survey-core'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faWandSparkles } from '@fortawesome/free-solid-svg-icons'
import { EnvironmentName } from 'src/types/study'
import { isEmpty, isNumber } from 'lodash'

/** button to automatically fill in a survey. this doesn't handle every single question type, but works with the more
* commonly tested forms like preEnroll. Only available in sandbox and irb environments. */
Expand All @@ -13,7 +14,11 @@ export function SurveyAutoCompleteButton({ surveyModel, envName }: {
if (surveyModel) {
surveyModel.pages.forEach(page => {
page.questions.forEach(question => {
if (question.readOnly || question.isReadOnly) {
const value = surveyModel.getValue(question.name)
if (question.readOnly
|| question.isReadOnly
|| (!isEmpty(value) || (isNumber(value) && value > 0))
) {
return
}

Expand Down

0 comments on commit bf74aa7

Please sign in to comment.