mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
fix(select) fall back to label text for title
This commit is contained in:
@ -4,6 +4,7 @@ import { deepCopy, isCheckedProperty } from '../../utils/helpers';
|
|||||||
|
|
||||||
import { ActionSheet } from '../action-sheet/action-sheet';
|
import { ActionSheet } from '../action-sheet/action-sheet';
|
||||||
import { Alert } from '../alert/alert';
|
import { Alert } from '../alert/alert';
|
||||||
|
import { Label } from '../label/label';
|
||||||
import { Popover } from '../popover/popover';
|
import { Popover } from '../popover/popover';
|
||||||
|
|
||||||
import { SelectOption } from '../select-option/select-option';
|
import { SelectOption } from '../select-option/select-option';
|
||||||
@ -31,7 +32,7 @@ export class Select {
|
|||||||
texts: any = [];
|
texts: any = [];
|
||||||
|
|
||||||
// TODO typing
|
// TODO typing
|
||||||
item: any;
|
label: Label;
|
||||||
|
|
||||||
options: SelectOption[] = [];
|
options: SelectOption[] = [];
|
||||||
overlay: ActionSheet | Alert | Popover;
|
overlay: ActionSheet | Alert | Popover;
|
||||||
@ -105,8 +106,8 @@ export class Select {
|
|||||||
|
|
||||||
|
|
||||||
componentDidLoad() {
|
componentDidLoad() {
|
||||||
// Get the parent item
|
// Get the nearest label
|
||||||
this.item = this.el.closest('ion-item');
|
this.label = this.el.closest('ion-item').querySelector('ion-label');
|
||||||
|
|
||||||
this.setOptions();
|
this.setOptions();
|
||||||
}
|
}
|
||||||
@ -332,8 +333,8 @@ export class Select {
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
// if the selectOptions didn't provide a title then use the label's text
|
// if the selectOptions didn't provide a title then use the label's text
|
||||||
if (!selectOptions.title && this.item) {
|
if (!selectOptions.title && this.label) {
|
||||||
selectOptions.title = this.item.getLabelText();
|
selectOptions.title = this.label.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the user passed in an invalid interface we need to reset it to alert
|
// If the user passed in an invalid interface we need to reset it to alert
|
||||||
|
Reference in New Issue
Block a user