mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 19:57:22 +08:00
fix(tabs): allow selection on enter and spacebar press (#18381)
fixes #18363
This commit is contained in:
@ -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');
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user