@@ -9,7 +9,8 @@ export const useSuggest = (
99 tagResult : QueryResult < Tags , { } > ,
1010 inputValue : string ,
1111 usedTags : string [ ] ,
12- skipValue = false
12+ skipValue = false ,
13+ includeInputValueOnNoMatch = true
1314) : TagSelectorEntry [ ] => {
1415 const [ tagKeySomeCase , tagValue ] = inputValue . split ( ':' ) ;
1516 const tagKey = tagKeySomeCase . toLowerCase ( ) ;
@@ -22,7 +23,7 @@ export const useSuggest = (
2223 } ) ;
2324
2425 if ( exactMatch && tagValue !== undefined && usedTags . indexOf ( exactMatch . key ) === - 1 && ! skipValue ) {
25- return suggestTagValue ( exactMatch , tagValue , valueResult ) ;
26+ return suggestTagValue ( exactMatch , tagValue , valueResult , includeInputValueOnNoMatch ) ;
2627 } else {
2728 return suggestTag ( exactMatch , tagResult , tagKey , usedTags ) ;
2829 }
@@ -59,11 +60,12 @@ const suggestTag = (
5960const suggestTagValue = (
6061 exactMatch : TagSelectorEntry [ 'tag' ] ,
6162 tagValue : string ,
62- valueResult : QueryResult < SuggestTagValue , SuggestTagValueVariables >
63+ valueResult : QueryResult < SuggestTagValue , SuggestTagValueVariables > ,
64+ includeInputValueOnNoMatch : boolean
6365) : TagSelectorEntry [ ] => {
6466 let someValues = ( valueResult . data && valueResult . data . values ) || [ ] ;
6567
66- if ( someValues . indexOf ( tagValue ) === - 1 ) {
68+ if ( includeInputValueOnNoMatch && someValues . indexOf ( tagValue ) === - 1 ) {
6769 someValues = [ tagValue , ...someValues ] ;
6870 }
6971
0 commit comments