Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private handleChange = ( event: any ) => {
const { input } = this.props
const selectedValues = input.value ? input.value.filter( ( item: string ) => !!item ) : []
if ( event.target.checked ) {
input.onChange( addValToArrayNoDup( selectedValues, event.target.value ), undefined, undefined )
}
else {
input.onChange( removeValFromArrayNoDup( selectedValues, event.target.value ), undefined, undefined )
}
}
private handleChoiceSelect = ( field: WrappedFieldProps, currentSelection: string[], choice: string, cmdOrCtrlKeyOn?: boolean ) => {
const newSelection: string[] = currentSelection.indexOf( choice ) !== -1
? removeValFromArrayNoDup( currentSelection as string[], choice )
: addValToArrayNoDup( currentSelection as string[], choice )
this.props.handleChange( {
target: {
value: currentSelection.indexOf( choice ) !== -1
? removeValFromArrayNoDup( currentSelection as string[], choice )
: addValToArrayNoDup( currentSelection as string[], choice ),
name: this.props.name
}
} )
if ( cmdOrCtrlKeyOn && this.dropdownCtn ) {
$( this.dropdownCtn ).removeClass( 'open' ).addClass( 'open' )
} else {
$( event.currentTarget ).scrollTop( 0 )
}
private handleChoiceSelect = ( field: WrappedFieldProps, currentSelection: string[], choice: string, cmdOrCtrlKeyOn?: boolean ) => {
const newSelection: string[] = currentSelection.indexOf( choice ) !== -1
? removeValFromArrayNoDup( currentSelection as string[], choice )
: addValToArrayNoDup( currentSelection as string[], choice )
this.props.handleChange( {
target: {
value: currentSelection.indexOf( choice ) !== -1
? removeValFromArrayNoDup( currentSelection as string[], choice )
: addValToArrayNoDup( currentSelection as string[], choice ),
name: this.props.name
}
} )
if ( cmdOrCtrlKeyOn && this.dropdownCtn ) {
$( this.dropdownCtn ).removeClass( 'open' ).addClass( 'open' )
} else {
$( event.currentTarget ).scrollTop( 0 )
}
field.input.onChange( newSelection.join( ',' ), undefined, undefined )
}