Skip to content

Commit

Permalink
Errors in the console when scrolling through the dropdown items - [In…
Browse files Browse the repository at this point in the history
…tervention] Ignored attempt to cancel a touchmove event with cancelable=false (#7340)

* Fixed #7283 - Errors in the console when scrolling through the dropdown items - [Intervention] Ignored attempt to cancel a touchmove event with cancelable=false

* Work for #7283 - Errors in the console when scrolling through the dropdown items - [Intervention] Ignored attempt to cancel a touchmove event with cancelable=false - fixed u-test

---------

Co-authored-by: tsv2013 <[email protected]>
  • Loading branch information
tsv2013 and tsv2013 authored Nov 14, 2023
1 parent df52ca7 commit 9347c59
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/popup-view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ export class PopupBaseViewModel extends Base {
}
currentElement = currentElement.parentElement;
}
event.preventDefault();
if (event.cancelable) {
event.preventDefault();
}
}
}
14 changes: 7 additions & 7 deletions tests/components/popuptests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,7 @@ QUnit.test("Check that modal popup prevents scroll outside", (assert) => {
let subscribeLog = "";
const wrapEvent = (event) => {
event.preventDefault = () => {
eventLog +="->prevented";
eventLog += "->prevented";
};
};
const wrapContainer = (element) => {
Expand Down Expand Up @@ -1565,40 +1565,40 @@ QUnit.test("Check that modal popup prevents scroll outside", (assert) => {
viewModel.updateOnShowing();
assert.equal(subscribeLog, "->subscribed");

let event = new WheelEvent("wheel", { deltaY: 20 });
let event = new WheelEvent("wheel", { deltaY: 20, cancelable: true });
wrapEvent(event);
container.dispatchEvent(event);
assert.equal(eventLog, "->prevented", "prevented scroll when not scrolling inside");

eventLog = "";
event = new WheelEvent("wheel", { deltaY: 20, bubbles: true });
event = new WheelEvent("wheel", { deltaY: 20, bubbles: true, cancelable: true });
wrapEvent(event);
container.children[0].children[0].dispatchEvent(event);
assert.equal(eventLog, "", "scroll inside (not prevented)");

eventLog = "";
event = new WheelEvent("wheel", { deltaY: -20, bubbles: true });
event = new WheelEvent("wheel", { deltaY: -20, bubbles: true, cancelable: true });
wrapEvent(event);
container.children[0].scrollTo(0, 20);
container.children[0].children[0].dispatchEvent(event);
assert.equal(eventLog, "", "scroll inside (not prevented)");

eventLog = "";
event = new WheelEvent("wheel", { deltaY: 20, bubbles: true });
event = new WheelEvent("wheel", { deltaY: 20, bubbles: true, cancelable: true });
wrapEvent(event);
container.children[0].scrollTo(0, 150);
container.children[0].children[0].dispatchEvent(event);
assert.equal(eventLog, "", "scroll inside (not prevented)");

eventLog = "";
event = new WheelEvent("wheel", { deltaY: -20, bubbles: true });
event = new WheelEvent("wheel", { deltaY: -20, bubbles: true, cancelable: true });
wrapEvent(event);
container.children[0].scrollTo(0, 0);
container.children[0].children[0].dispatchEvent(event);
assert.equal(eventLog, "->prevented", "overscroll inside (prevented)");

eventLog = "";
event = new WheelEvent("wheel", { deltaY: 20, bubbles: true });
event = new WheelEvent("wheel", { deltaY: 20, bubbles: true, cancelable: true });
wrapEvent(event);
container.children[0].scrollTo(0, 200);
container.children[0].children[0].dispatchEvent(event);
Expand Down

0 comments on commit 9347c59

Please sign in to comment.