mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 19:57:22 +08:00
fix(select): ensure popover options with number values are searched for correctly (#23998)
This commit is contained in:
@ -48,15 +48,18 @@ export class SelectPopover implements ComponentInterface {
|
||||
this.callOptionHandler(ev);
|
||||
}
|
||||
|
||||
private findOptionFromEvent(ev: any) {
|
||||
const { options } = this;
|
||||
return options.find(o => o.value === ev.target.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* When an option is selected we need to get the value(s)
|
||||
* of the selected option(s) and return it in the option
|
||||
* handler
|
||||
*/
|
||||
private callOptionHandler(ev: any) {
|
||||
const { options } = this;
|
||||
const option = options.find(o => this.getValue(o.value) === ev.target.value);
|
||||
|
||||
const option = this.findOptionFromEvent(ev);
|
||||
const values = this.getValues(ev);
|
||||
|
||||
if (option && option.handler) {
|
||||
@ -74,8 +77,8 @@ export class SelectPopover implements ComponentInterface {
|
||||
}
|
||||
|
||||
private setChecked(ev: any): void {
|
||||
const { multiple, options } = this;
|
||||
const option = options.find(o => this.getValue(o.value) === ev.target.value);
|
||||
const { multiple } = this;
|
||||
const option = this.findOptionFromEvent(ev);
|
||||
|
||||
// this is a popover with checkboxes (multiple value select)
|
||||
// we need to set the checked value for this option
|
||||
@ -95,14 +98,10 @@ export class SelectPopover implements ComponentInterface {
|
||||
|
||||
// this is a popover with radio buttons (single value select)
|
||||
// return the value that was clicked, otherwise undefined
|
||||
const option = options.find(o => this.getValue(o.value) === ev.target.value);
|
||||
const option = this.findOptionFromEvent(ev);
|
||||
return option ? option.value : undefined;
|
||||
}
|
||||
|
||||
private getValue(value: any): any {
|
||||
return typeof value === 'number' ? value.toString() : value;
|
||||
}
|
||||
|
||||
renderOptions(options: SelectPopoverOption[]) {
|
||||
const { multiple } = this;
|
||||
|
||||
|
Reference in New Issue
Block a user