-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AutoComplete: Delete chips using delete
key
#3127
Changes from 1 commit
00dde8e
0f8d58f
4e3ee49
f08d481
77f76b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -364,7 +364,18 @@ export class ModusAutocomplete { | |
this.valueChange.emit(search); | ||
}; | ||
|
||
handleChipDelete = (e,chip) => { | ||
if(e.key !="Delete") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its always safe to go with !== to validate the type as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Modified it, since e.key is the left operator and a keyboard input , i thought its always going to return the same time as the right operator is hardcoded |
||
return; | ||
} | ||
this.removeChip(chip) | ||
} | ||
|
||
handleCloseClick(chipValue: ModusAutocompleteOption) { | ||
this.removeChip(chipValue); | ||
} | ||
|
||
removeChip(chipValue: ModusAutocompleteOption) { | ||
if (this.selectedChips.length != 0 && !this.readOnly) { | ||
this.selectedChips = this.selectedChips.filter((chip) => chip.id !== chipValue.id); | ||
this.valueChange.emit(this.selectedChips.map((v) => v.value)); | ||
|
@@ -541,6 +552,7 @@ export class ModusAutocomplete { | |
value={chip.value} | ||
chipId={chip.id} | ||
disabled={this.disabled} | ||
onKeyDown={(e) => this.handleChipDelete(e,chip)} | ||
size={this.size === 'large' ? 'medium' : 'small'} | ||
show-close | ||
onCloseClick={() => this.handleCloseClick(chip)}></modus-chip> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the linter not throwing an error for missing space after the != ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
linter does it for css files, modified it