Matthias Mullie has uploaded a new change for review. https://gerrit.wikimedia.org/r/114991
Change subject: Bind to specific elements instead of random ...................................................................... Bind to specific elements instead of random this.$container can be whatever. It'll be whatever node .trigger( 'flow_init' ) is called upon. On init, that is $( document ) After moderation, that'll be .flow-post or flow-topic-container Because this.$container is not consistent, we can't rely on it to .on (and especially) .off event handlers. Initially, we bind to $( document ), then after moderation, we try to .off existing handlers on e.g. .flow-post, and bind the event anew. Result, no handlers were removed (there was nothing to .off on that element), and the handler is bound a second time, to another node. End result: things like double-collapse (immediately expand/ collapse) because a click is handled twice. Change-Id: I5c45b53bceb54386901cf24526d46383ada25804 --- M modules/discussion/ui.js 1 file changed, 8 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow refs/changes/91/114991/1 diff --git a/modules/discussion/ui.js b/modules/discussion/ui.js index b225a88..efcf2cd 100644 --- a/modules/discussion/ui.js +++ b/modules/discussion/ui.js @@ -126,6 +126,12 @@ $( this ).data( 'flow-initialised-topic', true ); } + + $( this ).find( '.flow-titlebar' ) + // Remove old event handlers + .off( '.mw-flow-discussion' ) + // On topic titlebar click, trigger collapse/expand event + .on( 'click.mw-flow-discussion', mw.flow.action.ui.titlebarClick ) } ); // init post interaction @@ -146,13 +152,10 @@ } } ); - this.$container - // Remove old event handlers + this.$container.find( '.topic-collapser li' ) .off( '.mw-flow-discussion' ) - // On topic titlebar click, trigger collapse/expand event - .on( 'click.mw-flow-discussion', '.flow-titlebar', mw.flow.action.ui.titlebarClick ) // On topic collapser click, choose a different collapsing level - .on( 'click.mw-flow-discussion', '.topic-collapser li', mw.flow.action.ui.topicCollapserClick ); + .on( 'click.mw-flow-discussion', mw.flow.action.ui.topicCollapserClick ); }, /** -- To view, visit https://gerrit.wikimedia.org/r/114991 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5c45b53bceb54386901cf24526d46383ada25804 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: Matthias Mullie <mmul...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits