From 363cf5c5dab90b00095229584eeac3d801d91bf2 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 8 Feb 2016 15:52:45 -0500 Subject: [PATCH] FIX: Couldn't like via keyboard --- .../discourse/lib/keyboard-shortcuts.js.es6 | 9 ++------- .../discourse/widgets/post-menu.js.es6 | 15 +++++++++++---- .../javascripts/discourse/widgets/post.js.es6 | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 b/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 index 45e888395..ccb4bd0fd 100644 --- a/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 +++ b/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 @@ -28,7 +28,7 @@ const bindings = { 'home': {handler: 'goToFirstPost', anonymous: true}, 'j': {handler: 'selectDown', anonymous: true}, 'k': {handler: 'selectUp', anonymous: true}, - 'l': {click: '.topic-post.selected button[data-action="like"]'}, + 'l': {click: '.topic-post.selected button.toggle-like'}, 'm m': {click: 'div.notification-options li[data-id="0"] a'}, // mark topic as muted 'm r': {click: 'div.notification-options li[data-id="1"] a'}, // mark topic as regular 'm t': {click: 'div.notification-options li[data-id="2"] a'}, // mark topic as tracking @@ -312,12 +312,7 @@ export default { } if ($article.is('.topic-post')) { - let tabLoc = $article.find('a.tabLoc'); - if (tabLoc.length === 0) { - tabLoc = $(''); - $article.prepend(tabLoc); - } - tabLoc.focus(); + $('a.tabLoc', $article).focus(); } this._scrollList($article, direction); diff --git a/app/assets/javascripts/discourse/widgets/post-menu.js.es6 b/app/assets/javascripts/discourse/widgets/post-menu.js.es6 index f4c4d9150..ec0d9b915 100644 --- a/app/assets/javascripts/discourse/widgets/post-menu.js.es6 +++ b/app/assets/javascripts/discourse/widgets/post-menu.js.es6 @@ -26,14 +26,21 @@ function registerButton(name, builder) { registerButton('like', attrs => { if (!attrs.showLike) { return; } - const className = attrs.liked ? 'has-like fade-out' : 'like'; + const className = attrs.liked ? 'toggle-like has-like fade-out' : 'toggle-like like'; + + const button = { + action: 'like', + icon: 'heart', + className + }; if (attrs.canToggleLike) { - const descKey = attrs.liked ? 'post.controls.undo_like' : 'post.controls.like'; - return { action: 'like', title: descKey, icon: 'heart', className }; + button.title = attrs.liked ? 'post.controls.undo_like' : 'post.controls.like'; } else if (attrs.liked) { - return { action: 'like', title: 'post.controls.has_liked', icon: 'heart', className, disabled: true }; + button.title = 'post.controls.has_liked'; + button.disabled = true; } + return button; }); registerButton('like-count', attrs => { diff --git a/app/assets/javascripts/discourse/widgets/post.js.es6 b/app/assets/javascripts/discourse/widgets/post.js.es6 index 26ed9f4e4..c55a6f855 100644 --- a/app/assets/javascripts/discourse/widgets/post.js.es6 +++ b/app/assets/javascripts/discourse/widgets/post.js.es6 @@ -315,7 +315,7 @@ createWidget('post-article', { }, html(attrs, state) { - const rows = []; + const rows = [h('a.tabLoc')]; if (state.repliesAbove.length) { const replies = state.repliesAbove.map(p => this.attach('embedded-post', p, { state: { above: true } })); rows.push(h('div.row', h('section.embedded-posts.top.topic-body.offset2', replies)));