fix(tabs): allow selection on enter and spacebar press (#18381)

fixes #18363
This commit is contained in:
Liam DeBeasi
2019-05-29 08:42:02 -04:00
committed by GitHub
parent 0fd3e5d4c5
commit 11cde99e20

View File

@ -63,6 +63,23 @@ export class TabButton implements ComponentInterface {
@Listen('click') @Listen('click')
onClick(ev: Event) { onClick(ev: Event) {
this.selectTab(ev);
}
@Listen('keyup')
onKeyUp(ev: KeyboardEvent) {
if (ev.key === 'Enter' || ev.key === ' ') {
this.selectTab(ev);
}
}
componentWillLoad() {
if (this.layout === undefined) {
this.layout = this.config.get('tabButtonLayout', 'icon-top');
}
}
private selectTab(ev: Event | KeyboardEvent) {
if (this.tab !== undefined) { if (this.tab !== undefined) {
if (!this.disabled) { if (!this.disabled) {
this.ionTabButtonClick.emit({ this.ionTabButtonClick.emit({
@ -75,12 +92,6 @@ export class TabButton implements ComponentInterface {
} }
} }
componentWillLoad() {
if (this.layout === undefined) {
this.layout = this.config.get('tabButtonLayout', 'icon-top');
}
}
private get hasLabel() { private get hasLabel() {
return !!this.el.querySelector('ion-label'); return !!this.el.querySelector('ion-label');
} }