Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue tap/click events should be mobile-aware #30

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading