Skip to content
Merged
Changes from all commits
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
13 changes: 11 additions & 2 deletions framework/core/js/src/forum/components/DiscussionListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import type { DiscussionListParams } from '../states/DiscussionListState';
export interface IDiscussionListItemAttrs extends ComponentAttrs {
discussion: Discussion;
params: DiscussionListParams;
slidable?: boolean;
}

/**
Expand Down Expand Up @@ -57,7 +58,7 @@ export default class DiscussionListItem<CustomAttrs extends IDiscussionListItemA
className: classList('DiscussionListItem', {
active: this.active(),
'DiscussionListItem--hidden': this.attrs.discussion.isHidden(),
Slidable: 'ontouchstart' in window,
Slidable: this.isSlidableEnabled(),
}),
};
}
Expand Down Expand Up @@ -198,13 +199,21 @@ export default class DiscussionListItem<CustomAttrs extends IDiscussionListItemA
return jumpTo;
}

protected isSlidableEnabled(): boolean {
if (this.attrs.slidable === false) {
return false;
}

return 'ontouchstart' in window;
}

oncreate(vnode: Mithril.VnodeDOM<CustomAttrs, this>) {
super.oncreate(vnode);

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

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