Skip to content

Commit

Permalink
fix: issue tap/click events should be mobile-aware
Browse files Browse the repository at this point in the history
Change to be committed :
modified: src/auro-backtotop.js
modified: test/auro-backtotop.test.js
  • Loading branch information
irma-kurnia-alaska committed Feb 27, 2024
1 parent e1ae327 commit 05a3372
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/auro-backtotop.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ export class AuroBackToTop extends LitElement {
this.addEventListener('focusout', () => {
this.interactionActive = false;
});

this.addEventListener('touchend', () => {
this.onTriggerClick();
});
}

// function that renders the HTML and CSS into the scope of the component
Expand Down
10 changes: 9 additions & 1 deletion test/auro-backtotop.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('auro-backtotop', () => {
});

it('auro-backtotop custom element is defined', async () => {
const el = await !!customElements.get("auro-backtotop");
const el = await Boolean(customElements.get("auro-backtotop"));

await expect(el).to.be.true;
});
Expand Down Expand Up @@ -62,6 +62,14 @@ describe('auro-backtotop', () => {
expect(el.interactionActive).to.be.false;
});

it('auro-backtotop event triggering event click', async () => {
const el = await fixture(html`
<auro-backtotop cssclass="testClass"></auro-backtotop>
`);
el.shadowRoot.querySelector('auro-button').click()
el.shadowRoot.querySelector('auro-button').dispatchEvent(new Event('mouseover'));
});

function simulateScroll(x, y) {
const scrollEvent = new CustomEvent('scroll', { detail: { x, y } });
window.scrollX = x;
Expand Down

0 comments on commit 05a3372

Please sign in to comment.