fix(select) fall back to label text for title

This commit is contained in:
Cam Wiegert
2017-12-07 14:26:19 -06:00
parent 2f02ab1ec5
commit 02d34a26aa

View File

@ -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