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 d6511e0df5
commit 6668e75019
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,6 +50,7 @@ export default class DiscussionListItem extends Component {
'DiscussionListItem',
this.active() ? 'active' : '',
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
// reveal controls.
if ('ontouchstart' in window) {
const slidableInstance = slidable(this.$().addClass('Slidable'));
const slidableInstance = slidable(this.$());
this.$('.DiscussionListItem-controls').on('hidden.bs.dropdown', () => slidableInstance.reset());
}