Skip to content
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

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,18 @@ export class ModusAutocomplete {
this.valueChange.emit(search);
};

handleChipDelete = (e,chip) => {
if(e.key !="Delete") {

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 != ?

Copy link
Collaborator Author

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its always safe to go with !== to validate the type as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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));
Expand Down Expand Up @@ -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>
Expand Down
Loading