Skip to content

Commit

Permalink
fix(ripple): ensure ripple occurs when a keyboard generated click hap…
Browse files Browse the repository at this point in the history
…pens after a pointer click

PiperOrigin-RevId: 527926090
  • Loading branch information
material-web-copybara authored and Copybara-Service committed Apr 28, 2023
1 parent 4c229d9 commit 016b851
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions ripple/lib/ripple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ export class Ripple extends LitElement {
}

private async endPressAnimation() {
this.state = State.INACTIVE;
const animation = this.growAnimation;
const pressAnimationPlayState = animation?.currentTime ?? Infinity;
if (pressAnimationPlayState >= MINIMUM_PRESS_MS) {
Expand Down
14 changes: 14 additions & 0 deletions ripple/lib/ripple_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ declare global {
class TestRipple extends Ripple {
}

interface WithState {
state: number;
}

describe('Ripple', () => {
const env = new Environment();

Expand Down Expand Up @@ -138,5 +142,15 @@ describe('Ripple', () => {

expect(surface).not.toHaveClass(RippleStateClasses.HOVERED);
});
it('responds to keyboard click after mouse click', async () => {
const {instance, harness} = await setupTest();
const STATE_INACTIVE = 0;
await harness.clickWithMouse();
await env.waitForStability();
expect((instance as unknown as WithState).state).toBe(STATE_INACTIVE);
await harness.clickWithKeyboard();
await env.waitForStability();
expect((instance as unknown as WithState).state).toBe(STATE_INACTIVE);
});
});
});

0 comments on commit 016b851

Please sign in to comment.