mirror of
https://github.com/material-components/material-web.git
synced 2024-09-11 13:46:10 +03:00
fix(ripple): ensure ripple occurs when a keyboard generated click happens after a pointer click
PiperOrigin-RevId: 527926090
This commit is contained in:
parent
4c229d9872
commit
016b8513e7
@ -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) {
|
||||
|
@ -30,6 +30,10 @@ declare global {
|
||||
class TestRipple extends Ripple {
|
||||
}
|
||||
|
||||
interface WithState {
|
||||
state: number;
|
||||
}
|
||||
|
||||
describe('Ripple', () => {
|
||||
const env = new Environment();
|
||||
|
||||
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user