mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
fix(select): placeholder can be reset if value = null
This commit is contained in:
@ -27,7 +27,7 @@ export class Select implements ComponentInterface {
|
|||||||
|
|
||||||
@State() isExpanded = false;
|
@State() isExpanded = false;
|
||||||
@State() keyFocus = false;
|
@State() keyFocus = false;
|
||||||
@State() text?: string | null;
|
@State() text = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The mode determines which platform styles to use.
|
* The mode determines which platform styles to use.
|
||||||
@ -164,10 +164,8 @@ export class Select implements ComponentInterface {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (texts.length > 0) {
|
|
||||||
this.text = texts.join(', ');
|
this.text = texts.join(', ');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// emit the new value
|
// emit the new value
|
||||||
this.ionChange.emit({
|
this.ionChange.emit({
|
||||||
@ -250,9 +248,7 @@ export class Select implements ComponentInterface {
|
|||||||
// fire off an unnecessary change event
|
// fire off an unnecessary change event
|
||||||
(this.value as string[]).push(o.value);
|
(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 {
|
} else {
|
||||||
const checked = this.childOpts.find(o => o.selected);
|
const checked = this.childOpts.find(o => o.selected);
|
||||||
@ -475,7 +471,7 @@ export class Select implements ComponentInterface {
|
|||||||
let addPlaceholderClass = false;
|
let addPlaceholderClass = false;
|
||||||
|
|
||||||
let selectText = this.selectedText || this.text;
|
let selectText = this.selectedText || this.text;
|
||||||
if (selectText == null && this.placeholder != null) {
|
if (selectText === '' && this.placeholder != null) {
|
||||||
selectText = this.placeholder;
|
selectText = this.placeholder;
|
||||||
addPlaceholderClass = true;
|
addPlaceholderClass = true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user