Skip to content

Commit

Permalink
fix(select): show placeholder when multiple is empty
Browse files Browse the repository at this point in the history
checks for array length before joining the array into this.text, this
prevents the text from being set to an empty string for a multiple
value select, allowing the placeholder to show
  • Loading branch information
brandyscarney committed Sep 19, 2018
1 parent 799f0d7 commit 29862e8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions core/src/components/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ export class Select implements ComponentInterface {
}
});

this.text = texts.join(', ');
if (texts.length > 0) {
this.text = texts.join(', ');
}
}

// emit the new value
Expand Down Expand Up @@ -248,7 +250,9 @@ export class Select implements ComponentInterface {
// fire off an unnecessary change event
(this.value as string[]).push(o.value);
});
this.text = checked.map(o => o.textContent).join(', ');
if (checked.map(o => o.textContent).length > 0) {
this.text = checked.map(o => o.textContent).join(', ');
}

} else {
const checked = this.childOpts.find(o => o.selected);
Expand Down Expand Up @@ -471,7 +475,7 @@ export class Select implements ComponentInterface {
let addPlaceholderClass = false;

let selectText = this.selectedText || this.text;
if (selectText === undefined && this.placeholder !== undefined) {
if (selectText == null && this.placeholder != null) {
selectText = this.placeholder;
addPlaceholderClass = true;
}
Expand Down

0 comments on commit 29862e8

Please sign in to comment.