Skip to content

Commit

Permalink
fix(tabs): allow selection on enter and spacebar press (#18381)
Browse files Browse the repository at this point in the history
fixes #18363
  • Loading branch information
liamdebeasi committed May 29, 2019
1 parent 0fd3e5d commit 11cde99
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions core/src/components/tab-button/tab-button.tsx
Expand Up @@ -63,6 +63,23 @@ export class TabButton implements ComponentInterface {

@Listen('click')
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.disabled) {
this.ionTabButtonClick.emit({
Expand All @@ -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() {
return !!this.el.querySelector('ion-label');
}
Expand Down

0 comments on commit 11cde99

Please sign in to comment.