Skip to content

Commit

Permalink
updated autocompltet (#521)
Browse files Browse the repository at this point in the history
  • Loading branch information
yerramshilpa authored Oct 7, 2020
1 parent f6a41ac commit 020f4ba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gsa-sam/sam-ui-elements",
"version": "1.0.14",
"version": "1.0.16",
"description": "SAM UI library",
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ export class SAMSDSAutocompleteSearchComponent implements ControlValueAccessor {
*/
@Input() public inputReadOnly = false;

public isItemSelected: boolean = false;


/**
* Stored Event for ControlValueAccessor
*/
Expand Down Expand Up @@ -234,9 +237,19 @@ export class SAMSDSAutocompleteSearchComponent implements ControlValueAccessor {
if (this.configuration.selectionMode === SelectionMode.SINGLE) {
const val = this.inputValue;
if (this.configuration.isTagModeEnabled || this.configuration.isFreeTextEnabled) {
SAMSDSSelectedItemModelHelper.clearItems(this.model);
this.propogateChange(this.model);
this.selectItem(this.createFreeTextItem(val));
if (
SAMSDSSelectedItemModelHelper.containsItem(
val,
this.configuration.primaryKeyField,
this.model.items
)
) {
SAMSDSSelectedItemModelHelper.clearItems(this.model);
this.propogateChange(this.model);
this.selectItem(this.createFreeTextItem(val));
} else {
this.selectItem(this.createFreeTextItem(val));
}
}
} else if (
this.configuration.selectionMode === SelectionMode.MULTIPLE
Expand Down Expand Up @@ -374,6 +387,7 @@ export class SAMSDSAutocompleteSearchComponent implements ControlValueAccessor {
* @param item
*/
public selectItem(item: object): void {
this.isItemSelected = true;
let filterItem = {};
if (this.essentialModelFields) {
filterItem[this.configuration.primaryKeyField] =
Expand Down Expand Up @@ -449,7 +463,7 @@ export class SAMSDSAutocompleteSearchComponent implements ControlValueAccessor {
if (selectedChild) {
selectedChild.scrollIntoView({
behavior: "smooth",
block: "center",
block: "nearest",
inline: "start",
});
}
Expand Down

0 comments on commit 020f4ba

Please sign in to comment.