Skip to content

Commit 90223f8

Browse files
authored
fix(ui5-li): fix active state on mobile (#1169)
1 parent 35b2593 commit 90223f8

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

packages/main/src/ListItem.hbs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
@keydown="{{_onkeydown}}"
99
@mouseup="{{_onmouseup}}"
1010
@mousedown="{{_onmousedown}}"
11+
@touchstart="{{_ontouchstart}}"
12+
@touchend="{{_ontouchend}}"
1113
@click="{{_onclick}}"
1214
>
1315
{{#if placeSelectionElementBefore}}

packages/main/src/ListItem.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { isSpace, isEnter } from "@ui5/webcomponents-base/dist/events/PseudoEvents.js";
2-
import { isDesktop } from "@ui5/webcomponents-base/dist/Device.js";
32
import "@ui5/webcomponents-icons/dist/icons/decline.js";
43
import ListItemType from "./types/ListItemType.js";
54
import ListMode from "./types/ListMode.js";
@@ -114,20 +113,19 @@ class ListItem extends ListItemBase {
114113
}
115114

116115
onBeforeRendering(...params) {
117-
const desktop = isDesktop();
118-
const isActionable = (this.type === ListItemType.Active) && (this._mode !== ListMode.Delete);
119-
120-
this.actionable = desktop && isActionable;
116+
this.actionable = (this.type === ListItemType.Active) && (this._mode !== ListMode.Delete);
121117
}
122118

123119
onEnterDOM() {
124120
document.addEventListener("mouseup", this.deactivate);
121+
document.addEventListener("touchend", this.deactivate);
125122
document.addEventListener("keyup", this.deactivateByKey);
126123
}
127124

128125
onExitDOM() {
129126
document.removeEventListener("mouseup", this.deactivate);
130127
document.removeEventListener("keyup", this.deactivateByKey);
128+
document.removeEventListener("touchend", this.deactivate);
131129
}
132130

133131
_onkeydown(event) {
@@ -172,6 +170,14 @@ class ListItem extends ListItemBase {
172170
this.deactivate();
173171
}
174172

173+
_ontouchstart(event) {
174+
this._onmousedown(event);
175+
}
176+
177+
_ontouchend(event) {
178+
this._onmouseup(event);
179+
}
180+
175181
_onfocusout() {
176182
super._onfocusout();
177183
this.deactivate();

0 commit comments

Comments
 (0)