diff --git a/atom/browser/api/lib/menu.coffee b/atom/browser/api/lib/menu.coffee index 039014433b07..442e54192862 100644 --- a/atom/browser/api/lib/menu.coffee +++ b/atom/browser/api/lib/menu.coffee @@ -68,6 +68,7 @@ Menu::insert = (pos, item) -> @groupsMap[item.groupId].push item # Setting a radio menu item should flip other items in the group. + v8Util.setHiddenValue item, 'checked', item.checked Object.defineProperty item, 'checked', enumerable: true get: -> v8Util.getHiddenValue item, 'checked' diff --git a/spec/api-menu-spec.coffee b/spec/api-menu-spec.coffee index 5ac7c14a7da6..729795c2a75d 100644 --- a/spec/api-menu-spec.coffee +++ b/spec/api-menu-spec.coffee @@ -36,13 +36,20 @@ describe 'menu module', -> ] menu.delegate.executeCommand menu.items[0].commandId - describe 'radio MenuItem', -> - it 'clicking an item should flip the checked property', -> - menu = Menu.buildFromTemplate [ label: 'text', type: 'radio' ] + describe 'MenuItem with checked property', -> + it 'clicking an checkbox item should flip the checked property', -> + menu = Menu.buildFromTemplate [ label: 'text', type: 'checkbox' ] assert.equal menu.items[0].checked, false menu.delegate.executeCommand menu.items[0].commandId assert.equal menu.items[0].checked, true + it 'clicking an radio item should always make checked property true', -> + menu = Menu.buildFromTemplate [ label: 'text', type: 'radio' ] + menu.delegate.executeCommand menu.items[0].commandId + assert.equal menu.items[0].checked, true + menu.delegate.executeCommand menu.items[0].commandId + assert.equal menu.items[0].checked, true + it 'at least have one item checked in each group', -> template = [] template.push label: "#{i}", type: 'radio' for i in [0..10]