Gmail-like comment manipulation keyboard shorcuts
|Reported by:||nbachiyski||Owned by:|
|Component:||General||Keywords:||js shortcuts has-patch|
j - down
k - up
x - mark (check the checkbox)
a - approve current comment (not checked)
u - unapprove
d - delete
s - spam
r - reply
Implemented as a generic jquery plugin and can be easily used on any table or list. Uses jquery-hotkeys. The main idea is:
jQuery.table_hotkeys(jQuery('table.widefat'), ['a', 'u', 's', 'd', 'r']); ... <tr class="some-css-class-prefix-current"> <a class="some-css-class-prefix-u" href="...">Unapprove</a> </tr>
The plugin cycles through rows of the given table and when one of the keys in the list is pressed, it looks for an element in that row with the proper class and clicks on it. In the example above, if I press u the Unapprove link of the current row will be clicked.
Known limitations and bugs:
- Bulk actions can't be triggered via the keyboard. If we want the interface to be consistent we have two options:
- Sacrifice either bulk shortcuts or single-comment shortcuts. I have chosen to drop bulk actions, because they need more attention (ergo, should be harder). Moreover, comments can be marked via the keyboard and if one wants to delete all comments the only action with the mouse will be to select Delete from the menu and click Apply.
- Choose different shortcuts for single-comment and bulk actions. For example Shift+u (aka U) can be bulk Unapprove and so on.
- Can't edit the comment because it is a normal link and they can't be clicked via JS. There is a workaround and we will work around it if needed.
- Clicking on an action button, which removes the comment from view, loses the currently selected comment and the user has to press j or k to bring the cursor back.
- The style for current comment is completely arbitrary (yellow background). Better ideas will be appreciated.