Skip to content

Commit 9b28a9a

Browse files
feat(core): allow to disable slidable on DiscussionListItem (#4302)
1 parent c772b9c commit 9b28a9a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

framework/core/js/src/forum/components/DiscussionListItem.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import type { DiscussionListParams } from '../states/DiscussionListState';
2424
export interface IDiscussionListItemAttrs extends ComponentAttrs {
2525
discussion: Discussion;
2626
params: DiscussionListParams;
27+
slidable?: boolean;
2728
}
2829

2930
/**
@@ -57,7 +58,7 @@ export default class DiscussionListItem<CustomAttrs extends IDiscussionListItemA
5758
className: classList('DiscussionListItem', {
5859
active: this.active(),
5960
'DiscussionListItem--hidden': this.attrs.discussion.isHidden(),
60-
Slidable: 'ontouchstart' in window,
61+
Slidable: this.isSlidableEnabled(),
6162
}),
6263
};
6364
}
@@ -198,13 +199,21 @@ export default class DiscussionListItem<CustomAttrs extends IDiscussionListItemA
198199
return jumpTo;
199200
}
200201

202+
protected isSlidableEnabled(): boolean {
203+
if (this.attrs.slidable === false) {
204+
return false;
205+
}
206+
207+
return 'ontouchstart' in window;
208+
}
209+
201210
oncreate(vnode: Mithril.VnodeDOM<CustomAttrs, this>) {
202211
super.oncreate(vnode);
203212

204213
// If we're on a touch device, set up the discussion row to be slidable.
205214
// This allows the user to drag the row to either side of the screen to
206215
// reveal controls.
207-
if ('ontouchstart' in window) {
216+
if (this.isSlidableEnabled()) {
208217
const slidableInstance = slidable(this.element);
209218

210219
this.$('.DiscussionListItem-controls').on('hidden.bs.dropdown', () => slidableInstance.reset());

0 commit comments

Comments
 (0)