Skip to content

Commit 556bcc3

Browse files
authored
fix(material/tabs): prevent page scroll on space press (#28532)
This appears to be a regression from #27862 where the `preventDefault` was removed both from space and enter presses. We still need it on space so that the page doesn't scroll. Fixes #28392.
1 parent 0499dc0 commit 556bcc3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/material/tabs/tab-nav-bar/tab-nav-bar.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,12 @@ export class MatTabLink
372372
if (this.disabled) {
373373
event.preventDefault();
374374
} else if (this._tabNavBar.tabPanel) {
375+
// Only prevent the default action on space since it can scroll the page.
376+
// Don't prevent enter since it can break link navigation.
377+
if (event.keyCode === SPACE) {
378+
event.preventDefault();
379+
}
380+
375381
this.elementRef.nativeElement.click();
376382
}
377383
}

0 commit comments

Comments
 (0)