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

Fix/select chips behaviour #719

Open
wants to merge 3 commits into
base: developer
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
refactor: using handler on add via click and enter
  • Loading branch information
Andrew Costa Silva committed Nov 14, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 9b7e4371b2e0526a2d02be5039abbe48b4be6fdd
15 changes: 4 additions & 11 deletions src/components/selects/select-chips/select-chips.tsx
Original file line number Diff line number Diff line change
@@ -402,24 +402,18 @@ export class SelectChips {
}
};

private close = (): void => {
if (!this.disabled) {
this.isOpen = false;
}
};

private handler = async (event: CustomEvent) => {
const {
detail: { value },
} = event;
const text = this.getText(value);
await this.addChip(text);
this.close();
this.handlerNewOption(text);
};

private handlerNewOption = async (text: string) => {
await this.addChip(text);
this.close();
this.clearInputValues();
this.resetFilterOptions();
};

private enableCreateOption(): boolean {
@@ -492,8 +486,7 @@ export class SelectChips {
case 'Enter':
if (this.canAddNew !== false) {
this.handleDelimiters();
this.setChip(this.value);
this.value = '';
this.handlerNewOption(this.value);
}
break;
case 'Backspace' || 'Delete':