mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
fix(select): show placeholder when multiple is empty
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
This commit is contained in:
@ -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
|
// emit the new value
|
||||||
@ -248,7 +250,9 @@ 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);
|
||||||
});
|
});
|
||||||
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 {
|
} else {
|
||||||
const checked = this.childOpts.find(o => o.selected);
|
const checked = this.childOpts.find(o => o.selected);
|
||||||
@ -471,7 +475,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 === undefined && this.placeholder !== undefined) {
|
if (selectText == null && this.placeholder != null) {
|
||||||
selectText = this.placeholder;
|
selectText = this.placeholder;
|
||||||
addPlaceholderClass = true;
|
addPlaceholderClass = true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user