Skip to content

Commit

Permalink
fix(stack-view): prevent page scroll when block toggled via space key
Browse files Browse the repository at this point in the history
VPAT-636: "When I press space on the live website the page scrolls down
in addition to the expanding/collapsing. This should work like the
accordion component." -- comment by Amy Li
  • Loading branch information
kevinbuhmann committed Oct 11, 2022
1 parent e1e974f commit 234445a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions projects/angular/src/data/stack-view/stack-block.ts
Expand Up @@ -24,11 +24,14 @@ import { ClrStackViewLabel } from './stack-view-custom-tags';
@Component({
selector: 'clr-stack-block',
template: `
<!-- The 'preventDefault' for the space keydown event prevents the page
from scrolling when a stack block is toggled via the space key. -->
<div
class="stack-block-label"
(click)="toggleExpand()"
(keyup.enter)="toggleExpand()"
(keyup.space)="toggleExpand()"
(keydown.space)="$event.preventDefault()"
(focus)="focused = true"
(blur)="focused = false"
[id]="uniqueId"
Expand Down

0 comments on commit 234445a

Please sign in to comment.