@@ -29,7 +29,7 @@ import { isTestEnv } from '../../util/utils';
2929
3030import { useTimeout } from '../../hooks' ;
3131
32- import { SelectInputOption , SelectInput , SelectInputProps , SelectInputChange } from './input/SelectInput' ;
32+ import { SelectInput , SelectInputChange , SelectInputOption , SelectInputProps } from './input/SelectInput' ;
3333import { resolveDetailFieldLabel } from './utils' ;
3434import {
3535 fetchSearchResults ,
@@ -86,8 +86,8 @@ export interface QuerySelectOptionProps extends Pick<SelectInputOption, 'label'
8686type QuerySelectOptionComponent = ComponentType < QuerySelectOptionProps > ;
8787
8888interface OptionRendererProps extends Pick < SelectInputOption , 'label' | 'value' > {
89- OptionComponent ?: QuerySelectOptionComponent ;
9089 model : QuerySelectModel ;
90+ OptionComponent ?: QuerySelectOptionComponent ;
9191}
9292
9393const OptionRenderer : FC < OptionRendererProps > = props => {
@@ -161,20 +161,20 @@ type InheritedSelectInputProps = Omit<
161161 | 'labelKey'
162162 | 'loadOptions'
163163 | 'onChange' // overridden by QuerySelect. See onQSChange().
164- | 'options'
165164 | 'optionRenderer' // overridden by QuerySelect. Use "OptionComponent" instead.
165+ | 'options'
166166 | 'selectedOptions'
167167 | 'valueKey'
168168> ;
169169
170170export interface QuerySelectOwnProps extends InheritedSelectInputProps {
171- OptionComponent ?: QuerySelectOptionComponent ;
172171 autoInit ?: boolean ;
173172 containerFilter ?: Query . ContainerFilter ;
174173 /** The path to the LK container that the queries should be scoped to. */
175174 containerPath ?: string ;
176175 delimiter ?: string ;
177176 displayColumn ?: string ;
177+ displaySelectedOptions ?: boolean ;
178178 fireQSChangeOnInit ?: boolean ;
179179 groupByColumn ?: string ;
180180 loadOnFocus ?: boolean ;
@@ -183,6 +183,7 @@ export interface QuerySelectOwnProps extends InheritedSelectInputProps {
183183 notFoundValuesEnabled ?: boolean ;
184184 onInitValue ?: ( value : any , selectedValues : List < any > ) => void ;
185185 onQSChange ?: QuerySelectChange ;
186+ OptionComponent ?: QuerySelectOptionComponent ;
186187 preLoad ?: boolean ;
187188 queryFilters ?: List < Filter . IFilter > ;
188189 queryParams ?: Record < string , any > ;
@@ -197,7 +198,7 @@ type DefaultOptions = boolean | SelectInputOption[];
197198type Search = {
198199 input : string ;
199200 reject : ( reason ?: any ) => any ;
200- resolve : ( value : SelectInputOption [ ] | PromiseLike < SelectInputOption [ ] > ) => void ;
201+ resolve : ( value : PromiseLike < SelectInputOption [ ] > | SelectInputOption [ ] ) => void ;
201202} ;
202203
203204export const QuerySelect : FC < QuerySelectOwnProps > = memo ( props => {
@@ -209,6 +210,7 @@ export const QuerySelect: FC<QuerySelectOwnProps> = memo(props => {
209210 containerPath,
210211 delimiter = DELIMITER ,
211212 displayColumn,
213+ displaySelectedOptions = true ,
212214 fireQSChangeOnInit = false ,
213215 groupByColumn,
214216 loadOnFocus = false ,
@@ -268,7 +270,7 @@ export const QuerySelect: FC<QuerySelectOwnProps> = memo(props => {
268270 const debounceTO = useTimeout ( ) ;
269271 const shouldLoadOnFocus = loadOnFocus && ! loadOnFocusLock ;
270272 const { notFoundValues, selectedOptions } = useMemo ( ( ) => {
271- const notFoundValues_ = new Set < string | number | boolean > ( ) ;
273+ const notFoundValues_ = new Set < boolean | number | string > ( ) ;
272274 const options = model . isInit ? model . selectedOptions : undefined ;
273275
274276 if ( options ) {
@@ -416,7 +418,7 @@ export const QuerySelect: FC<QuerySelectOwnProps> = memo(props => {
416418
417419 const optionRenderer = useCallback (
418420 option => (
419- < OptionRenderer OptionComponent = { OptionComponent } label = { option . label } model = { model } value = { option . value } />
421+ < OptionRenderer label = { option . label } model = { model } OptionComponent = { OptionComponent } value = { option . value } />
420422 ) ,
421423 [ OptionComponent , model ]
422424 ) ;
@@ -440,8 +442,8 @@ export const QuerySelect: FC<QuerySelectOwnProps> = memo(props => {
440442 formsy = { formsy }
441443 helpTipRenderer = { helpTipRenderer }
442444 initiallyDisabled = { initiallyDisabled }
443- isLoading = { false }
444445 inputClass = { inputClass }
446+ isLoading = { false }
445447 label = { label }
446448 labelClass = { labelClass }
447449 menuPosition = { menuPosition }
@@ -474,7 +476,7 @@ export const QuerySelect: FC<QuerySelectOwnProps> = memo(props => {
474476 options = { undefined } // prevent override
475477 // Issue 52773: Allow for submission of required fields whose value is not found
476478 required = { notFoundValues . size > 0 ? false : required }
477- selectedOptions = { selectedOptions }
479+ selectedOptions = { displaySelectedOptions ? selectedOptions : undefined }
478480 value = { getValue ( model , multiple ) } // needed to initialize the Formsy "value" properly
479481 warning = { warning }
480482 />
0 commit comments