Commit Graph

41 Commits

Author SHA1 Message Date
Jordan Eldredge
7a60c9920c Allow packages to control the order of context menu items 2018-01-31 16:35:15 -08:00
Jordan Eldredge
228f65da5f Base context menu accelerators on activeElement
Addresses issue pointed by out @nathansobo in #15277 where keybindings
for unfocusable nodes were being surfaced as accelerator indicators in
context menus.

When you right click in the DOM, your focus goes to the first focusable
ancestor of your click target. This change uses the ancestor that you
are actually focused on when looking for avaliable key bindings rather
than using the event target directly. This ensures that any surfaced key
bindings are actually reachable.
2017-08-16 11:58:05 -07:00
Jordan Eldredge
e71d8d863c Add accelerator indicators to context menus
Electron allows us to pass an "accelerator" property for each menu item, which
is renders to the right of the menu item. We were already adding these for the
application level menus.

This pull request adds the accelerator property to regular context menu items,
which should make it easier for people to discover/recall key mappings for
actions which they usually take via a context menu.
2017-08-12 15:00:44 -07:00
Antonio Scandurra
284f2c62e5 Start fixing tests 2017-03-11 19:05:28 +01:00
Wliu
bf463d59c8 Unfocus specs
/cc @damieng
2016-08-25 22:44:57 -04:00
Damien Guard
0f88949832
Remove all redundant separators 2016-08-25 12:49:29 -07:00
Damien Guard
d44dbb373d
Remove trailing context menu separator fixing #5390 2016-08-24 21:45:21 -07:00
Michael Bolin
83d3168609 Rename test function as suggested by @maxbrunsfeld. 2016-01-25 13:19:58 -08:00
Michael Bolin
ee4408976e Tightened up a test now that I confirmed that MenuHelpers.merge() intentionally strips the created field. 2016-01-21 10:18:04 -08:00
Michael Bolin
0e4a8303ae Apparently the created function is stripped as part of the clone? 2016-01-18 18:32:37 -08:00
Michael Bolin
0a4817693f Add unit test. Cannot seem to run locally because of nodegit but will see what happens in CI. 2016-01-18 16:50:16 -08:00
Nathan Sobo
6de0da792b Build ContextMenuManager in Atom environment constructor 2015-10-07 15:24:52 -05:00
Thomas Johansen
cc4ee92699 🔥 Remove deprecations from ContextMenuManager 2015-09-22 10:37:05 -06:00
Nathan Sobo
6ccb9573c6 Drop unused requires 2015-09-18 20:48:46 -06:00
Kevin Sawicki
5902bc42e9 Throw error when adding context menu with invalid selector 2015-03-04 10:02:03 -08:00
Ben Ogle
9cec02420c Suppress deprecations while testing legacy code path 2014-11-26 14:55:40 -08:00
Ben Ogle
43ccf0a041 Convert require ‘atom’ to require '../src/space-pen-extensions' 2014-11-26 14:55:38 -08:00
Nathan Sobo
6ce5356505 Fix handling of submenus in conversion of legacy context menu format 2014-10-02 10:47:03 -06:00
Nathan Sobo
4a0c5aaa70 Prevent adjacent menu separators 2014-09-30 12:06:27 -06:00
Nathan Sobo
eb929cb7a2 Honor item specificity while still preserving addition order
Rather than using order to specify item precedence, we now construct
a set of menu items for each element traversing upward from the target.
When merging items for a given element, we pass the specificity to the
merge function, which uses it to decide whether or not to clobber
existing items. When assembling the overall menu, we don’t ever clobber
to ensure that items added for elements closer to the target always win
over items matching further up the tree.
2014-09-30 12:06:27 -06:00
Nathan Sobo
36d5359ef4 Restore original context menu ordering
Previously I used CSS specificity to order the most specific / recently
added menu items for a given element *first* when building up the
context menu. When a duplicate label was found for a given menu I would
refrain from inserting it. Now instead I order things the opposite way.
The most specific / recently added items come later and items with the
same label are clobbered by later items.
2014-09-30 12:06:26 -06:00
Nathan Sobo
782f9c609e Add shouldDisplay hook for context menu items
If present, if a falsy value is returned from this function for a given
context menu invocation, the item will not be displayed.
2014-09-30 12:06:09 -06:00
Nathan Sobo
3a567b3c5b Call context menu item ::created hooks with the click event 2014-09-30 12:06:08 -06:00
Nathan Sobo
c5b395579b Add devMode flag to individual items 2014-09-30 12:06:08 -06:00
Nathan Sobo
f8225a6441 Make arguments atom.contextMenu.add consistent with atom.menu.add 2014-09-30 12:06:08 -06:00
Ivan Zuzak
861dff107a 💄 simplify assignment using coffeescript magic 2014-08-28 19:42:59 +02:00
Ivan Zuzak
096255f283 Support built-in context menu items 2014-08-27 13:54:55 +02:00
Ivan Zuzak
cd1a17fb0a Support multiple separators in context menu 2014-07-14 17:10:13 -07:00
Philip Schatz
67a1ed92db 💄 context menu tests 2014-06-19 19:14:34 -04:00
Philip Schatz
624c0bf9f1 allow multiple labels for the same command 2014-06-17 23:36:59 -04:00
Philip Schatz
2fdcf7a124 remove duplicate context menu entries 2014-06-13 21:30:55 -04:00
Corey Johnson
0f551d4b11 Add expectations to context-menu specs 2014-06-03 10:44:45 -07:00
Corey Johnson
35a7bb115d Fix context-menu specs 2014-06-03 10:44:45 -07:00
Corey Johnson
8ed3b7a250 Merge pull request #2134 from erikhakansson/AdvancedContextMenu
Advanced context menu
2014-06-03 10:13:37 -07:00
Kevin Sawicki
bcad8c1b3e Remove # which is interpreted as a tag
This spec was not running because of it since
jasmine-tagged is configured to filter tags by
process.platform
2014-06-02 10:17:13 -07:00
Erik Håkansson
a90039baab fixes to spec 2014-05-24 23:52:08 +02:00
Erik Håkansson
55228f9667 updated coding style and added spec 2014-05-24 23:52:08 +02:00
Erik Håkansson
6295c2ddc4 minor changes 2014-05-24 23:52:08 +02:00
Matt Colyer
ca3f645301 Fix requires 2013-09-20 14:14:17 -07:00
Matt Colyer
e8125defb9 Update specs to match latest changes 2013-09-19 14:55:17 -07:00
Matt Colyer
c39ced381d Implement declarative context menu loading 2013-09-19 14:21:31 -07:00