Skip to content

Commit 30f2dc7

Browse files
authored
fix: make listeners passive (#5012)
1 parent 883809f commit 30f2dc7

File tree

8 files changed

+65
-28
lines changed

8 files changed

+65
-28
lines changed

packages/base/hash.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Qztq2lzPEMPQUMmcTqNy+GZ3Aig=
1+
1xd6xbRotmYM0O01qxhGL8Fk17E=

packages/main/src/Button.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,18 @@ class Button extends UI5Element {
356356

357357
isGlobalHandlerAttached = true;
358358
}
359+
360+
this._ontouchstart = {
361+
handleEvent(event) {
362+
event.isMarked = "button";
363+
if (this.nonInteractive) {
364+
return;
365+
}
366+
367+
this.active = true;
368+
},
369+
passive: true,
370+
};
359371
}
360372

361373
onEnterDOM() {
@@ -397,15 +409,6 @@ class Button extends UI5Element {
397409
activeButton = this; // eslint-disable-line
398410
}
399411

400-
_ontouchstart(event) {
401-
event.isMarked = "button";
402-
if (this.nonInteractive) {
403-
return;
404-
}
405-
406-
this.active = true;
407-
}
408-
409412
_ontouchend(event) {
410413
this.active = false;
411414

packages/main/src/ListItem.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@ class ListItem extends ListItemBase {
148148
this.active = false;
149149
}
150150
};
151+
152+
this._ontouchstart = {
153+
handleEvent(event) {
154+
this._onmousedown(event);
155+
},
156+
passive: true,
157+
};
151158
}
152159

153160
onBeforeRendering(...params) {
@@ -212,10 +219,6 @@ class ListItem extends ListItemBase {
212219
this.deactivate();
213220
}
214221

215-
_ontouchstart(event) {
216-
this._onmousedown(event);
217-
}
218-
219222
_ontouchend(event) {
220223
this._onmouseup(event);
221224
}

packages/main/src/SliderBase.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,13 @@ class SliderBase extends UI5Element {
159159
max: null,
160160
labelInterval: null,
161161
};
162+
163+
this._ontouchstart = {
164+
handleEvent(event) {
165+
this._onmousedown(event);
166+
},
167+
passive: true,
168+
};
162169
}
163170

164171
static get metadata() {
@@ -255,10 +262,6 @@ class SliderBase extends UI5Element {
255262
}
256263
}
257264

258-
_ontouchstart(event) {
259-
this._onmousedown(event);
260-
}
261-
262265
/** Shows the tooltip(s) if the <code>showTooltip</code> property is set to true
263266
*
264267
* @private

packages/main/src/SplitButton.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,19 @@ class SplitButton extends UI5Element {
302302
SplitButton.i18nBundle = await getI18nBundle("@ui5/webcomponents");
303303
}
304304

305+
constructor() {
306+
super();
307+
308+
this._textButtonPress = {
309+
handleEvent(event) {
310+
this._textButtonActive = true;
311+
this.focused = false;
312+
this._setTabIndexValue();
313+
},
314+
passive: true,
315+
};
316+
}
317+
305318
onBeforeRendering() {
306319
this._textButtonIcon = this.textButton && this.activeIcon !== "" && (this._textButtonActive) && !this._shiftOrEscapePressed ? this.activeIcon : this.icon;
307320
if (this.disabled) {
@@ -383,12 +396,6 @@ class SplitButton extends UI5Element {
383396
this._setTabIndexValue();
384397
}
385398

386-
_textButtonPress() {
387-
this._textButtonActive = true;
388-
this.focused = false;
389-
this._setTabIndexValue();
390-
}
391-
392399
_setTabIndexValue() {
393400
const textButton = this.textButton,
394401
arrowButton = this.arrowButton,

packages/main/src/TableRow.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,17 @@ class TableRow extends UI5Element {
191191
return [CheckBox];
192192
}
193193

194+
constructor() {
195+
super();
196+
197+
this._ontouchstart = {
198+
handleEvent(event) {
199+
this.activate();
200+
},
201+
passive: true,
202+
};
203+
}
204+
194205
_onmouseup() {
195206
this.deactivate();
196207
}
@@ -240,10 +251,6 @@ class TableRow extends UI5Element {
240251
}
241252
}
242253

243-
_ontouchstart(event) {
244-
this.activate();
245-
}
246-
247254
_ontouchend() {
248255
this.deactivate();
249256
}

packages/main/src/TimePickerBase.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,13 @@ class TimePickerBase extends UI5Element {
442442
this._updateValueAndFireEvents(newValue, true, ["change", "value-changed"]);
443443
}
444444

445+
/**
446+
*
447+
* @param {event} e Wheel Event
448+
* @private
449+
*
450+
* The listener for this event can't be passive as it calls preventDefault()
451+
*/
445452
_handleWheel(e) {
446453
e.preventDefault();
447454
}

packages/main/src/WheelSlider.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,13 @@ class WheelSlider extends UI5Element {
342342
return index;
343343
}
344344

345+
/**
346+
*
347+
* @param {event} e Wheel Event
348+
* @private
349+
*
350+
* The listener for this event can't be passive as it calls preventDefault()
351+
*/
345352
_handleWheel(e) {
346353
if (!e) {
347354
return;

0 commit comments

Comments
 (0)