Bug 1208047 - Close the dropdown menu for sharing on Loop's conversation window as soon as an item is clicked, rather than leaving it open in a potentially confusing state. r=mikedeboer,a=lhenry
authorMark Banner <standard8@mozilla.com>
Tue, 06 Oct 2015 16:05:50 +0100
changeset 296296 92b041da4873289d08688b5b2f30029b111144d8
parent 296295 c858e82f02058ce6510662d6bebf60c6d024ce2e
child 296297 dd2e90cfe88ade3cd2863ab2a0b2d03621a25001
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer, lhenry
bugs1208047
milestone43.0a2
Bug 1208047 - Close the dropdown menu for sharing on Loop's conversation window as soon as an item is clicked, rather than leaving it open in a potentially confusing state. r=mikedeboer,a=lhenry
browser/components/loop/content/shared/js/views.js
browser/components/loop/content/shared/js/views.jsx
browser/components/loop/test/shared/views_test.js
--- a/browser/components/loop/content/shared/js/views.js
+++ b/browser/components/loop/content/shared/js/views.js
@@ -115,20 +115,22 @@ loop.shared.views = (function(_, mozL10n
     _startScreenShare: function(type) {
       this.props.dispatcher.dispatch(new sharedActions.StartScreenShare({
         type: type
       }));
     },
 
     _handleShareTabs: function() {
       this._startScreenShare("browser");
+      this.hideDropdownMenu();
     },
 
     _handleShareWindows: function() {
       this._startScreenShare("window");
+      this.hideDropdownMenu();
     },
 
     _getTitle: function() {
       var prefix = this.props.state === SCREEN_SHARE_STATES.ACTIVE ?
         "active" : "inactive";
 
       return mozL10n.get(prefix + "_screenshare_button_title");
     },
--- a/browser/components/loop/content/shared/js/views.jsx
+++ b/browser/components/loop/content/shared/js/views.jsx
@@ -115,20 +115,22 @@ loop.shared.views = (function(_, mozL10n
     _startScreenShare: function(type) {
       this.props.dispatcher.dispatch(new sharedActions.StartScreenShare({
         type: type
       }));
     },
 
     _handleShareTabs: function() {
       this._startScreenShare("browser");
+      this.hideDropdownMenu();
     },
 
     _handleShareWindows: function() {
       this._startScreenShare("window");
+      this.hideDropdownMenu();
     },
 
     _getTitle: function() {
       var prefix = this.props.state === SCREEN_SHARE_STATES.ACTIVE ?
         "active" : "inactive";
 
       return mozL10n.get(prefix + "_screenshare_button_title");
     },
--- a/browser/components/loop/test/shared/views_test.js
+++ b/browser/components/loop/test/shared/views_test.js
@@ -171,16 +171,32 @@ describe("loop.shared.views", function()
         TestUtils.Simulate.click(comp.getDOMNode().querySelector(
           ".screen-share-menu > li"));
 
         sinon.assert.calledOnce(dispatcher.dispatch);
         sinon.assert.calledWithExactly(dispatcher.dispatch,
           new sharedActions.StartScreenShare({ type: "browser" }));
       });
 
+    it("should close the dropdown on 'browser' option click", function() {
+      var comp = TestUtils.renderIntoDocument(
+        React.createElement(sharedViews.ScreenShareControlButton, {
+          dispatcher: dispatcher,
+          visible: true,
+          state: SCREEN_SHARE_STATES.INACTIVE
+        }));
+
+      sandbox.stub(comp, "hideDropdownMenu");
+
+      TestUtils.Simulate.click(comp.getDOMNode().querySelector(
+        ".screen-share-menu > li"));
+
+      sinon.assert.calledOnce(comp.hideDropdownMenu);
+    });
+
     it("should dispatch a 'window' StartScreenShare action on option click",
       function() {
         var comp = TestUtils.renderIntoDocument(
           React.createElement(sharedViews.ScreenShareControlButton, {
             dispatcher: dispatcher,
             visible: true,
             state: SCREEN_SHARE_STATES.INACTIVE
           }));
@@ -188,16 +204,32 @@ describe("loop.shared.views", function()
         TestUtils.Simulate.click(comp.getDOMNode().querySelector(
           ".screen-share-menu > li:last-child"));
 
         sinon.assert.calledOnce(dispatcher.dispatch);
         sinon.assert.calledWithExactly(dispatcher.dispatch,
           new sharedActions.StartScreenShare({ type: "window" }));
       });
 
+    it("should close the dropdown on 'window' option click", function() {
+      var comp = TestUtils.renderIntoDocument(
+        React.createElement(sharedViews.ScreenShareControlButton, {
+          dispatcher: dispatcher,
+          visible: true,
+          state: SCREEN_SHARE_STATES.INACTIVE
+        }));
+
+      sandbox.stub(comp, "hideDropdownMenu");
+
+      TestUtils.Simulate.click(comp.getDOMNode().querySelector(
+        ".screen-share-menu > li:last-child"));
+
+      sinon.assert.calledOnce(comp.hideDropdownMenu);
+    });
+
     it("should have the 'window' option enabled", function() {
       var comp = TestUtils.renderIntoDocument(
         React.createElement(sharedViews.ScreenShareControlButton, {
           dispatcher: dispatcher,
           visible: true,
           state: SCREEN_SHARE_STATES.INACTIVE
         }));