Skip to content

Commit

Permalink
fix(select): placeholder can be reset if value = null
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Sep 25, 2018
1 parent e18f8bf commit 602f668
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions core/src/components/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class Select implements ComponentInterface {

@State() isExpanded = false;
@State() keyFocus = false;
@State() text?: string | null;
@State() text = '';

/**
* The mode determines which platform styles to use.
Expand Down Expand Up @@ -164,9 +164,7 @@ export class Select implements ComponentInterface {
}
});

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

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

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

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

0 comments on commit 602f668

Please sign in to comment.