mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-23 20:19:03 +01:00
Summary: In D16157, dropdown menus got an overly-broad check for not closing when an item is clicked. Specifically, we don't want to close the menu if the item is really opening a submenu, like "Edit Related Objects..." does on mobile. The check for this is too broad, and also doesn't close the menu if the item has workflow. Instead, use a narrower check. Test Plan: - Menu still stays open when toggling submenus like "Edit Related Objects". - Menu now closes properly when using workflow items like "Edit Comment" or "Remove Comment". Reviewers: chad Reviewed By: chad Differential Revision: https://secure.phabricator.com/D17210
61 lines
1.4 KiB
JavaScript
61 lines
1.4 KiB
JavaScript
/**
|
|
* @provides javelin-behavior-phui-dropdown-menu
|
|
* @requires javelin-behavior
|
|
* javelin-stratcom
|
|
* javelin-dom
|
|
* phuix-dropdown-menu
|
|
*/
|
|
|
|
JX.behavior('phui-dropdown-menu', function() {
|
|
|
|
JX.Stratcom.listen('click', 'phui-dropdown-menu', function(e) {
|
|
var data = e.getNodeData('phui-dropdown-menu');
|
|
if (data.menu) {
|
|
return;
|
|
}
|
|
|
|
e.kill();
|
|
|
|
var list;
|
|
var placeholder;
|
|
if (data.items) {
|
|
list = JX.$H(data.items).getFragment().firstChild;
|
|
} else {
|
|
list = JX.$(data.menuID);
|
|
placeholder = JX.$N('span');
|
|
}
|
|
|
|
var icon = e.getNode('phui-dropdown-menu');
|
|
data.menu = new JX.PHUIXDropdownMenu(icon);
|
|
|
|
data.menu.listen('open', function() {
|
|
if (placeholder) {
|
|
JX.DOM.replace(list, placeholder);
|
|
}
|
|
data.menu.setContent(list);
|
|
});
|
|
|
|
data.menu.listen('close', function() {
|
|
if (placeholder) {
|
|
JX.DOM.replace(placeholder, list);
|
|
}
|
|
});
|
|
|
|
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();
|
|
});
|
|
});
|
|
|
|
});
|