Skip to content

Commit 839667d

Browse files
asyncLizcopybara-github
authored andcommitted
perf(ripple): don't process events in high contrast mode
PiperOrigin-RevId: 591368699
1 parent cc8d02c commit 839667d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

ripple/internal/ripple.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ const EVENTS = [
8787
*/
8888
const TOUCH_DELAY_MS = 150;
8989

90+
/**
91+
* Used to detect if HCM is active. Events do not process during HCM when the
92+
* ripple is not displayed.
93+
*/
94+
const FORCED_COLORS = isServer
95+
? null
96+
: window.matchMedia('(forced-colors: active)');
97+
9098
/**
9199
* A ripple component.
92100
*/
@@ -438,6 +446,11 @@ export class Ripple extends LitElement implements Attachable {
438446

439447
/** @private */
440448
async handleEvent(event: Event) {
449+
if (FORCED_COLORS?.matches) {
450+
// Skip event logic since the ripple is `display: none`.
451+
return;
452+
}
453+
441454
switch (event.type) {
442455
case 'click':
443456
this.handleClick();

0 commit comments

Comments
 (0)