mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Remove trailing context menu separator fixing #5390
This commit is contained in:
@@ -149,6 +149,17 @@ describe "ContextMenuManager", ->
|
||||
shouldDisplay = false
|
||||
expect(contextMenu.templateForEvent(dispatchedEvent)).toEqual []
|
||||
|
||||
it "prunes a trailing separator", ->
|
||||
contextMenu.add
|
||||
'.grandchild': [
|
||||
{label: 'A', command: 'a'},
|
||||
{type: 'separator'},
|
||||
{label: 'B', command: 'b'},
|
||||
{type: 'separator'}
|
||||
]
|
||||
|
||||
expect(contextMenu.templateForEvent({target: grandchild}).length).toBe(3)
|
||||
|
||||
it "throws an error when the selector is invalid", ->
|
||||
addError = null
|
||||
try
|
||||
|
||||
@@ -145,6 +145,10 @@ class ContextMenuManager
|
||||
|
||||
currentTarget = currentTarget.parentElement
|
||||
|
||||
# Remove trailing separator
|
||||
if template.length > 0 and template[template.length - 1].type is 'separator'
|
||||
template.splice(template.length-1, 1)
|
||||
|
||||
template
|
||||
|
||||
# Returns an object compatible with `::add()` or `null`.
|
||||
|
||||
Reference in New Issue
Block a user