Fix mobile controls gesture on discussion deletion/restoration (#2324)

Because the Slidable class was always added on creation, it was lost every time the class list changed (in this case when the discussion was hidden/unhidden which added/removed DiscussionListItem--hidden class). So by determining the Slidable class's presence in elementAttrs() method, it guarantees it always properly set.
This commit is contained in:
Sami Mazouz 2020-09-29 00:07:05 +01:00 committed by GitHub
parent 948ac359dc
commit 922cb8bb11

View File

@ -50,6 +50,7 @@ export default class DiscussionListItem extends Component {
'DiscussionListItem', 'DiscussionListItem',
this.active() ? 'active' : '', this.active() ? 'active' : '',
this.attrs.discussion.isHidden() ? 'DiscussionListItem--hidden' : '', this.attrs.discussion.isHidden() ? 'DiscussionListItem--hidden' : '',
'ontouchstart' in window ? 'Slidable' : '',
]), ]),
}; };
} }
@ -136,7 +137,7 @@ export default class DiscussionListItem extends Component {
// This allows the user to drag the row to either side of the screen to // This allows the user to drag the row to either side of the screen to
// reveal controls. // reveal controls.
if ('ontouchstart' in window) { if ('ontouchstart' in window) {
const slidableInstance = slidable(this.$().addClass('Slidable')); const slidableInstance = slidable(this.$());
this.$('.DiscussionListItem-controls').on('hidden.bs.dropdown', () => slidableInstance.reset()); this.$('.DiscussionListItem-controls').on('hidden.bs.dropdown', () => slidableInstance.reset());
} }