Skip to content

Commit aba285b

Browse files
Pause homepage hero when it has mouse hover or focus (microsoft#10937)
Improves accessibility of page as focus is no longer lost to the document body. Co-authored-by: Richard Knoll <riknoll@users.noreply.github.com>
1 parent 69f378c commit aba285b

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎webapp/src/projects.tsx‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,8 @@ class HeroBanner extends data.Component<ISettingsProps, HeroBannerState> {
429429
if (!paused) {
430430
this.clearRefresh();
431431
this.carouselTimeout = setTimeout(this.handleRefreshCard, HERO_BANNER_DELAY);
432+
} else {
433+
this.clearRefresh();
432434
}
433435
}
434436

@@ -505,6 +507,14 @@ class HeroBanner extends data.Component<ISettingsProps, HeroBannerState> {
505507
return this.prevGalleries;
506508
}
507509

510+
pause = () => {
511+
this.setState({ paused: true });
512+
}
513+
514+
resume = () => {
515+
this.setState({ paused: false });
516+
}
517+
508518
renderCore() {
509519
const targetTheme = pxt.appTarget.appTheme;
510520
const { cardIndex } = this.state;
@@ -531,6 +541,10 @@ class HeroBanner extends data.Component<ISettingsProps, HeroBannerState> {
531541
aria-label={lf("Banner")}
532542
onPointerDown={this.onPointerDown} onTouchStart={this.onTouchstart}
533543
onPointerUp={this.onPointerUp} onTouchEnd={this.onTouchEnd}
544+
onFocus={this.pause}
545+
onBlur={this.resume}
546+
onMouseOver={this.pause}
547+
onMouseLeave={this.resume}
534548
>
535549
{(!!description || hasAction || isGallery) && <div className="gradient-overlay" />}
536550
<div className="hero-banner-contents">

0 commit comments

Comments
 (0)