1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 21:40:55 +01:00

Attempt to make dropdown item actions more consistent

Summary:
See D17210. Currently, this handler needs to be installed on each menu that doesn't build with the default behavior.

Rather than copy-pasting it to the user menu, try to make it a default behavior. This adds a new rule: don't close the menu if the item is a dynamic item built in JS with PHUIXActionView.

This allows dynamic items to control the menu themselves, while giving static items the desired default behavior.

Test Plan:
  - Opened menus on: dashboards, user menu, timeline comments. Clicked stuff. Menus went away.
  - Other menus still seemed to work right: Diffusion, Favorites, mobile menu.

Reviewers: chad

Reviewed By: chad

Differential Revision: https://secure.phabricator.com/D17222
This commit is contained in:
epriestley 2017-01-18 11:17:11 -08:00
parent 90258ed491
commit 45c3aaeb26
5 changed files with 66 additions and 57 deletions

View file

@ -10,7 +10,7 @@ return array(
'conpherence.pkg.css' => '0b64e988', 'conpherence.pkg.css' => '0b64e988',
'conpherence.pkg.js' => '6249a1cf', 'conpherence.pkg.js' => '6249a1cf',
'core.pkg.css' => 'e75e4f9d', 'core.pkg.css' => 'e75e4f9d',
'core.pkg.js' => 'f70cb91f', 'core.pkg.js' => '2291d3b2',
'darkconsole.pkg.js' => 'e7393ebb', 'darkconsole.pkg.js' => 'e7393ebb',
'differential.pkg.css' => '9535a7e6', 'differential.pkg.css' => '9535a7e6',
'differential.pkg.js' => 'ddfeb49b', 'differential.pkg.js' => 'ddfeb49b',
@ -443,7 +443,7 @@ return array(
'rsrc/js/application/projects/WorkboardCard.js' => 'c587b80f', 'rsrc/js/application/projects/WorkboardCard.js' => 'c587b80f',
'rsrc/js/application/projects/WorkboardColumn.js' => '21df4ff5', 'rsrc/js/application/projects/WorkboardColumn.js' => '21df4ff5',
'rsrc/js/application/projects/WorkboardController.js' => '55baf5ed', 'rsrc/js/application/projects/WorkboardController.js' => '55baf5ed',
'rsrc/js/application/projects/behavior-project-boards.js' => '14a1faae', 'rsrc/js/application/projects/behavior-project-boards.js' => '93ae974f',
'rsrc/js/application/projects/behavior-project-create.js' => '065227cc', 'rsrc/js/application/projects/behavior-project-create.js' => '065227cc',
'rsrc/js/application/projects/behavior-reorder-columns.js' => 'e1d25dfb', 'rsrc/js/application/projects/behavior-reorder-columns.js' => 'e1d25dfb',
'rsrc/js/application/releeph/releeph-preview-branch.js' => 'b2b4fbaf', 'rsrc/js/application/releeph/releeph-preview-branch.js' => 'b2b4fbaf',
@ -534,14 +534,14 @@ return array(
'rsrc/js/core/behavior-watch-anchor.js' => '9f36c42d', 'rsrc/js/core/behavior-watch-anchor.js' => '9f36c42d',
'rsrc/js/core/behavior-workflow.js' => '0a3f3021', 'rsrc/js/core/behavior-workflow.js' => '0a3f3021',
'rsrc/js/core/phtize.js' => 'd254d646', 'rsrc/js/core/phtize.js' => 'd254d646',
'rsrc/js/phui/behavior-phui-dropdown-menu.js' => '8744dfd1', 'rsrc/js/phui/behavior-phui-dropdown-menu.js' => 'b95d6f7d',
'rsrc/js/phui/behavior-phui-file-upload.js' => 'b003d4fb', 'rsrc/js/phui/behavior-phui-file-upload.js' => 'b003d4fb',
'rsrc/js/phui/behavior-phui-submenu.js' => 'a6f7a73b', 'rsrc/js/phui/behavior-phui-submenu.js' => 'a6f7a73b',
'rsrc/js/phui/behavior-phui-tab-group.js' => '0a0b10e9', 'rsrc/js/phui/behavior-phui-tab-group.js' => '0a0b10e9',
'rsrc/js/phuix/PHUIXActionListView.js' => 'b5c256b8', 'rsrc/js/phuix/PHUIXActionListView.js' => 'b5c256b8',
'rsrc/js/phuix/PHUIXActionView.js' => '9cc178ed', 'rsrc/js/phuix/PHUIXActionView.js' => 'b3465b9b',
'rsrc/js/phuix/PHUIXAutocomplete.js' => '6d86ce8b', 'rsrc/js/phuix/PHUIXAutocomplete.js' => '6d86ce8b',
'rsrc/js/phuix/PHUIXDropdownMenu.js' => '82e270da', 'rsrc/js/phuix/PHUIXDropdownMenu.js' => '8018ee50',
'rsrc/js/phuix/PHUIXFormControl.js' => 'bbece68d', 'rsrc/js/phuix/PHUIXFormControl.js' => 'bbece68d',
'rsrc/js/phuix/PHUIXIconView.js' => 'bff6884b', 'rsrc/js/phuix/PHUIXIconView.js' => 'bff6884b',
), ),
@ -687,14 +687,14 @@ return array(
'javelin-behavior-phabricator-watch-anchor' => '9f36c42d', 'javelin-behavior-phabricator-watch-anchor' => '9f36c42d',
'javelin-behavior-pholio-mock-edit' => 'bee502c8', 'javelin-behavior-pholio-mock-edit' => 'bee502c8',
'javelin-behavior-pholio-mock-view' => 'fbe497e7', 'javelin-behavior-pholio-mock-view' => 'fbe497e7',
'javelin-behavior-phui-dropdown-menu' => '8744dfd1', 'javelin-behavior-phui-dropdown-menu' => 'b95d6f7d',
'javelin-behavior-phui-file-upload' => 'b003d4fb', 'javelin-behavior-phui-file-upload' => 'b003d4fb',
'javelin-behavior-phui-hovercards' => 'bcaccd64', 'javelin-behavior-phui-hovercards' => 'bcaccd64',
'javelin-behavior-phui-submenu' => 'a6f7a73b', 'javelin-behavior-phui-submenu' => 'a6f7a73b',
'javelin-behavior-phui-tab-group' => '0a0b10e9', 'javelin-behavior-phui-tab-group' => '0a0b10e9',
'javelin-behavior-policy-control' => 'd0c516d5', 'javelin-behavior-policy-control' => 'd0c516d5',
'javelin-behavior-policy-rule-editor' => '5e9f347c', 'javelin-behavior-policy-rule-editor' => '5e9f347c',
'javelin-behavior-project-boards' => '14a1faae', 'javelin-behavior-project-boards' => '93ae974f',
'javelin-behavior-project-create' => '065227cc', 'javelin-behavior-project-create' => '065227cc',
'javelin-behavior-quicksand-blacklist' => '7927a7d3', 'javelin-behavior-quicksand-blacklist' => '7927a7d3',
'javelin-behavior-read-only-warning' => 'ba158207', 'javelin-behavior-read-only-warning' => 'ba158207',
@ -898,9 +898,9 @@ return array(
'phui-workcard-view-css' => 'cca5fa92', 'phui-workcard-view-css' => 'cca5fa92',
'phui-workpanel-view-css' => 'a3a63478', 'phui-workpanel-view-css' => 'a3a63478',
'phuix-action-list-view' => 'b5c256b8', 'phuix-action-list-view' => 'b5c256b8',
'phuix-action-view' => '9cc178ed', 'phuix-action-view' => 'b3465b9b',
'phuix-autocomplete' => '6d86ce8b', 'phuix-autocomplete' => '6d86ce8b',
'phuix-dropdown-menu' => '82e270da', 'phuix-dropdown-menu' => '8018ee50',
'phuix-form-control-view' => 'bbece68d', 'phuix-form-control-view' => 'bbece68d',
'phuix-icon-view' => 'bff6884b', 'phuix-icon-view' => 'bff6884b',
'policy-css' => '957ea14c', 'policy-css' => '957ea14c',
@ -1044,15 +1044,6 @@ return array(
'javelin-dom', 'javelin-dom',
'javelin-history', 'javelin-history',
), ),
'14a1faae' => array(
'javelin-behavior',
'javelin-dom',
'javelin-util',
'javelin-vector',
'javelin-stratcom',
'javelin-workflow',
'javelin-workboard-controller',
),
'185bbd53' => array( '185bbd53' => array(
'javelin-install', 'javelin-install',
), ),
@ -1519,6 +1510,13 @@ return array(
'javelin-behavior', 'javelin-behavior',
'javelin-history', 'javelin-history',
), ),
'8018ee50' => array(
'javelin-install',
'javelin-util',
'javelin-dom',
'javelin-vector',
'javelin-stratcom',
),
'805b806a' => array( '805b806a' => array(
'javelin-magical-init', 'javelin-magical-init',
'javelin-install', 'javelin-install',
@ -1526,13 +1524,6 @@ return array(
'javelin-vector', 'javelin-vector',
'javelin-stratcom', 'javelin-stratcom',
), ),
'82e270da' => array(
'javelin-install',
'javelin-util',
'javelin-dom',
'javelin-vector',
'javelin-stratcom',
),
'834a1173' => array( '834a1173' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-scrollbar', 'javelin-scrollbar',
@ -1561,12 +1552,6 @@ return array(
'phabricator-tooltip', 'phabricator-tooltip',
'changeset-view-manager', 'changeset-view-manager',
), ),
'8744dfd1' => array(
'javelin-behavior',
'javelin-stratcom',
'javelin-dom',
'phuix-dropdown-menu',
),
'88236f00' => array( '88236f00' => array(
'javelin-behavior', 'javelin-behavior',
'phabricator-keyboard-shortcut', 'phabricator-keyboard-shortcut',
@ -1639,6 +1624,15 @@ return array(
'javelin-stratcom', 'javelin-stratcom',
'javelin-dom', 'javelin-dom',
), ),
'93ae974f' => array(
'javelin-behavior',
'javelin-dom',
'javelin-util',
'javelin-vector',
'javelin-stratcom',
'javelin-workflow',
'javelin-workboard-controller',
),
'93d0c9e3' => array( '93d0c9e3' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-stratcom', 'javelin-stratcom',
@ -1699,11 +1693,6 @@ return array(
'javelin-workflow', 'javelin-workflow',
'javelin-stratcom', 'javelin-stratcom',
), ),
'9cc178ed' => array(
'javelin-install',
'javelin-dom',
'javelin-util',
),
'9d9685d6' => array( '9d9685d6' => array(
'phui-oi-list-view-css', 'phui-oi-list-view-css',
), ),
@ -1849,6 +1838,11 @@ return array(
'javelin-uri', 'javelin-uri',
'javelin-request', 'javelin-request',
), ),
'b3465b9b' => array(
'javelin-install',
'javelin-dom',
'javelin-util',
),
'b3a4b884' => array( 'b3a4b884' => array(
'javelin-behavior', 'javelin-behavior',
'phabricator-prefab', 'phabricator-prefab',
@ -1901,6 +1895,12 @@ return array(
'javelin-json', 'javelin-json',
'phabricator-draggable-list', 'phabricator-draggable-list',
), ),
'b95d6f7d' => array(
'javelin-behavior',
'javelin-stratcom',
'javelin-dom',
'phuix-dropdown-menu',
),
'ba158207' => array( 'ba158207' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-uri', 'javelin-uri',

View file

@ -34,13 +34,6 @@ JX.behavior('project-boards', function(config, statics) {
data.menu = new JX.PHUIXDropdownMenu(button); data.menu = new JX.PHUIXDropdownMenu(button);
data.menu.setContent(list); data.menu.setContent(list);
data.menu.open(); data.menu.open();
JX.DOM.listen(list, 'click', 'tag:a', function(e) {
if (!e.isNormalClick()) {
return;
}
data.menu.close();
});
}); });
JX.Stratcom.listen( JX.Stratcom.listen(

View file

@ -42,20 +42,6 @@ JX.behavior('phui-dropdown-menu', function() {
}); });
data.menu.open(); data.menu.open();
JX.DOM.listen(list, 'click', 'tag:a', function(e) {
if (!e.isNormalClick()) {
return;
}
// If this item opens a submenu, we don't want to close the current
// menu. One submenu is "Edit Related Objects..." on mobile.
if (JX.Stratcom.hasSigil(e.getTarget(), 'keep-open')) {
return;
}
data.menu.close();
});
}); });
}); });

View file

@ -96,6 +96,8 @@ JX.install('PHUIXActionView', {
className: classes.join(' ') className: classes.join(' ')
}; };
this._node = JX.$N('li', attr, content); this._node = JX.$N('li', attr, content);
JX.Stratcom.addSigil(this._node, 'phuix-action-view');
} }
return this._node; return this._node;

View file

@ -40,6 +40,12 @@ JX.install('PHUIXDropdownMenu', {
JX.Stratcom.listen('phuix.dropdown.open', null, JX.bind(this, this.close)); JX.Stratcom.listen('phuix.dropdown.open', null, JX.bind(this, this.close));
JX.Stratcom.listen('keydown', null, JX.bind(this, this._onkey)); JX.Stratcom.listen('keydown', null, JX.bind(this, this._onkey));
JX.DOM.listen(
this._getMenuNode(),
'click',
'tag:a',
JX.bind(this, this._onlink));
}, },
events: ['open', 'close'], events: ['open', 'close'],
@ -112,6 +118,28 @@ JX.install('PHUIXDropdownMenu', {
e.prevent(); e.prevent();
}, },
_onlink: function(e) {
if (!e.isNormalClick()) {
return;
}
// If this action was built dynamically with PHUIXActionView, don't
// do anything by default. The caller is repsonsible for installing a
// handler if they want to react to clicks.
if (e.getNode('phuix-action-view')) {
return;
}
// If this item opens a submenu, we don't want to close the current
// menu. One submenu is "Edit Related Objects..." on mobile.
var link = e.getNode('tag:a');
if (JX.Stratcom.hasSigil(link, 'keep-open')) {
return;
}
this.close();
},
_onanyclick : function(e) { _onanyclick : function(e) {
if (!this._open) { if (!this._open) {
return; return;