@@ -56,8 +56,11 @@ class SkillsQuestion extends React.PureComponent {
5656 . then ( resp => {
5757 const options = _ . get ( resp , 'data' , [ ] )
5858
59- cachedOptions = options
60- this . updateOptions ( options )
59+ cachedOptions = options . map ( ( option ) => ( {
60+ skillId : option . id ,
61+ name : option . name
62+ } ) )
63+ this . updateOptions ( cachedOptions )
6164 } )
6265 } else {
6366 this . updateOptions ( cachedOptions )
@@ -81,7 +84,7 @@ class SkillsQuestion extends React.PureComponent {
8184 this . setState ( { options } )
8285 this . updateAvailableOptions ( this . props , options )
8386 if ( onSkillsLoaded ) {
84- onSkillsLoaded ( options . map ( ( option ) => _ . pick ( option , [ 'id' , 'name' ] ) ) )
87+ onSkillsLoaded ( options )
8588 }
8689 }
8790
@@ -97,7 +100,6 @@ class SkillsQuestion extends React.PureComponent {
97100
98101 // if have a mapping for categories, then filter options, otherwise use all options
99102 const availableOptions = getAvailableOptions ( categoriesMapping , selectedCategories , skillsCategories , options )
100- . map ( option => _ . pick ( option , [ 'id' , 'name' ] ) )
101103 this . setState ( { availableOptions } )
102104 }
103105
@@ -186,17 +188,17 @@ class SkillsQuestion extends React.PureComponent {
186188 const selectedCategories = _ . get ( currentProjectData , categoriesField , [ ] )
187189
188190 let currentValues = getValue ( ) || [ ]
189- // remove from currentValues not available options but still keep created custom options without id
190- currentValues = currentValues . filter ( skill => _ . some ( availableOptions , skill ) || ! skill . id )
191+ // remove from currentValues not available options but still keep created custom options without 'skillId'
192+ currentValues = currentValues . filter ( skill => _ . some ( availableOptions , skill ) || ! skill . skillId )
191193
192194 const questionDisabled = isFormDisabled ( ) || disabled || ( selectedCategories . length === 0 && _ . isUndefined ( skillsCategories ) )
193195 const hasError = ! isPristine ( ) && ! isValid ( )
194196 const errorMessage = getErrorMessage ( ) || validationError
195197
196- const checkboxGroupOptions = availableOptions . filter ( option => frequentSkills . indexOf ( option . id ) > - 1 )
197- const checkboxGroupValues = currentValues . filter ( val => _ . some ( checkboxGroupOptions , option => option . id === val . id ) )
198+ const checkboxGroupOptions = availableOptions . filter ( option => frequentSkills . indexOf ( option . skillId ) > - 1 )
199+ const checkboxGroupValues = currentValues . filter ( val => _ . some ( checkboxGroupOptions , option => option . skillId === val . skillId ) )
198200
199- const selectGroupOptions = availableOptions . filter ( option => frequentSkills . indexOf ( option . id ) === - 1 )
201+ const selectGroupOptions = availableOptions . filter ( option => frequentSkills . indexOf ( option . skillId ) === - 1 )
200202 if ( customOptionValue ) {
201203 selectGroupOptions . unshift ( { name : customOptionValue } )
202204 }
0 commit comments