From 88e2929411be1e5d7b86a9b3605009c1febf67de Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 21 Jan 2016 10:02:01 -0800 Subject: [PATCH] Fix "choose icon" on profile menu items Summary: Ref T10054. This fix is a little rough but the "right" fix involves a ton of rewriting to `AphrontSideNavFilterView` and I don't want to open that can of worms up yet. Specifically, the problem is: - we build the menu in order to populate the mobile/application menu; - as a side effect of building the menu (not rendering the menu), we initialize the menu collapse/expand behavior; - but we never actually render the menu, so the `JX.$()` call fails. The right fix would be to initialize the behavior only when we render the menu, but then `AphorntSideNavFilterView` would need to know about profile menu behaviors. It probably should some day, but I think today is not that day. Test Plan: Set icons on a link on a profile menu. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10054 Differential Revision: https://secure.phabricator.com/D15073 --- resources/celerity/map.php | 6 +++--- webroot/rsrc/js/phui/behavior-phui-profile-menu.js | 13 ++++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index a8f0d881ce..23726438a7 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -500,7 +500,7 @@ return array( 'rsrc/js/core/phtize.js' => 'd254d646', 'rsrc/js/phui/behavior-phui-dropdown-menu.js' => '54733475', 'rsrc/js/phui/behavior-phui-object-box-tabs.js' => '2bfa2836', - 'rsrc/js/phui/behavior-phui-profile-menu.js' => 'bf2c93d6', + 'rsrc/js/phui/behavior-phui-profile-menu.js' => 'bfc2e675', 'rsrc/js/phuix/PHUIXActionListView.js' => 'b5c256b8', 'rsrc/js/phuix/PHUIXActionView.js' => '8cf6d262', 'rsrc/js/phuix/PHUIXAutocomplete.js' => '21dc9144', @@ -649,7 +649,7 @@ return array( 'javelin-behavior-pholio-mock-view' => 'fbe497e7', 'javelin-behavior-phui-dropdown-menu' => '54733475', 'javelin-behavior-phui-object-box-tabs' => '2bfa2836', - 'javelin-behavior-phui-profile-menu' => 'bf2c93d6', + 'javelin-behavior-phui-profile-menu' => 'bfc2e675', 'javelin-behavior-policy-control' => 'ae45872f', 'javelin-behavior-policy-rule-editor' => '5e9f347c', 'javelin-behavior-project-boards' => 'ba4fa35c', @@ -1774,7 +1774,7 @@ return array( 'javelin-util', 'javelin-request', ), - 'bf2c93d6' => array( + 'bfc2e675' => array( 'javelin-behavior', 'javelin-stratcom', 'javelin-dom', diff --git a/webroot/rsrc/js/phui/behavior-phui-profile-menu.js b/webroot/rsrc/js/phui/behavior-phui-profile-menu.js index bd305b5cf2..28d01ec122 100644 --- a/webroot/rsrc/js/phui/behavior-phui-profile-menu.js +++ b/webroot/rsrc/js/phui/behavior-phui-profile-menu.js @@ -6,7 +6,18 @@ */ JX.behavior('phui-profile-menu', function(config) { - var menu_node = JX.$(config.menuID); + // NOTE: This behavior is not initialized in the rendering pipeline for the + // menu, so it can get initialized when we build but do not render a menu + // (for example, when a page like the panel edit page only has items in + // the mobile/application menu, and does not show the profile menu). For now, + // just bail if we can't find the menu. + + try { + var menu_node = JX.$(config.menuID); + } catch (ex) { + return; + } + var collapse_node = JX.$(config.collapseID); var is_collapsed = config.isCollapsed;