steelbrain / intentions

Base package for showing intentions in Atom
MIT License
53 stars 11 forks source link

Clicking menu doesn't trigger action #28

Open Arcanemagus opened 8 years ago

Arcanemagus commented 8 years ago

When a menu is presented: image

Pressing Enter will apply the fix, but clicking on the item only closes the menu, no action is performed.

steelbrain commented 8 years ago

The reason behind this was that we dispose the list on mousedown and were listening for click event on the list, if we listen for mousedown instead, we have the expected correct behavior

Arcanemagus commented 8 years ago

Managed to break this again on 64b4503c33de301b290b64e893d9c05a24431545:

  1. Open the menu with the keybind (Alt + Enter)
  2. Close the menu with the keybind (Esc)
  3. Open the menu with the kebind again
  4. Click on the menu option

The menu will go away, but the action isn't triggered.

pablooliveira commented 7 years ago

I'm still experiencing this behavior with 1.1.4 release. The menu only works the first time. The second time it's opened, pressing the key "down" exits the menu and clicking on the menu options do not trigger the actions.

pablooliveira commented 7 years ago

Actually, in my case, the problem is due to a bad interaction with vim-mode-plus. When pressing Esc to close the menu, command mode is selected.

It seems, that the intentions menu only works well with vim-mode-plus when in insert mode.

Arcanemagus commented 7 years ago

@pablooliveira You'll have to file an issue on vim-mode-plus about it breaking other packages...

pablooliveira commented 7 years ago

Actually, I'm not sure which of the two packages is breaking the other. The way intentions catches core:move-up, core:move-down actions in lib/commands.js without declaring explicitly the bindings in keymaps/intentions.json seems curious.

pablooliveira commented 7 years ago

I found a simple workaround for my issue with vim-mode-plus. The problem is that in command mode, vim-mode-plus remaps the following keys: up, down and escape to its own actions. Therefore intentions do not see the events core:move-up, core:move-down ad core:escape.

I just add the following to my user's keymap.cson to ensure that when using an intentions-list, escape, down, and up are mapped to core events.

'atom-text-editor.intentions-list:not([mini]):not(.fake-attribute-to-increase-specificity)':
  'escape': 'intentions:hide'
  'down': 'core:move-down'
  'up': 'core:move-up'

I'm hesitant to report this as a bug in vim-mode-plus, because I see nothing wrong in remapping those keys. Shouldn't it be intentions responsability to ensure that when in an intentions-list, the correct events are generated ?

clamydo commented 7 years ago

Thx for the workaround. I also had to add 'enter': 'intentions:confirm', so in total

'atom-text-editor.intentions-list:not([mini]):not(.fake-attribute-to-increase-specificity)':
  'escape': 'intentions:hide'
  'down': 'core:move-down'
  'up': 'core:move-up'
  'enter': 'intentions:confirm