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: disable cancelSyntheticClickEvents globally #3510

Merged
merged 3 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions packages/component-base/src/element-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
* Copyright (c) 2021 - 2022 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
import { setCancelSyntheticClickEvents } from '@polymer/polymer/lib/utils/settings.js';
import { usageStatistics } from '@vaadin/vaadin-usage-statistics/vaadin-usage-statistics.js';
import { idlePeriod } from './async.js';
import { Debouncer, enqueueDebouncer } from './debounce.js';
import { DirMixin } from './dir-mixin.js';

// This setting affects the legacy Polymer gestures which get activated
// once you import any iron component e.g iron-icon.
// It has to be explicitly disabled to prevent click issues in iOS + VoiceOver
// for buttons that are based on `[role=button]` e.g vaadin-button.
setCancelSyntheticClickEvents(false);

window.Vaadin = window.Vaadin || {};

/**
Expand Down
22 changes: 22 additions & 0 deletions packages/component-base/test/element-mixin.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect } from '@esm-bundle/chai';
import { click, touchend, touchstart } from '@vaadin/testing-helpers';
import sinon from 'sinon';
import { PolymerElement } from '@polymer/polymer/polymer-element.js';
import { flush } from '../src/debounce.js';
Expand Down Expand Up @@ -35,6 +36,27 @@ describe('ElementMixin', () => {
});
});

describe('cancelSyntheticClickEvents', () => {
let button;

beforeEach(() => {
button = document.createElement('div');
vursen marked this conversation as resolved.
Show resolved Hide resolved
document.body.appendChild(button);
});

afterEach(() => {
button.remove();
});

it('should disable cancelSyntheticClickEvents globally', async () => {
await import('@polymer/polymer/lib/utils/gestures.js');
touchstart(button);
touchend(button);
const event = click(button);
expect(event.__polymerGesturesHandled).to.be.undefined;
tomivirkki marked this conversation as resolved.
Show resolved Hide resolved
});
});

describe('version', () => {
let XElement;

Expand Down