UX: Make the .selected class follow focus

This commit is contained in:
Kane York 2018-01-15 18:22:08 -08:00 committed by Guo Xiang Tan
parent 3212cdda78
commit 59b7760e2e

View File

@ -89,6 +89,8 @@ export default {
this._bindToClick(binding.click, key);
}
});
this._bindFocus();
},
toggleBookmark() {
@ -308,6 +310,19 @@ export default {
}
},
_bindFocus() {
const addSelected = function(e, addOrRemove) {
const row = '.topic-post, .topic-list-item, .topic-list tbody tr';
const $wrapper = $(e.target).closest(row);
const $srcWrapper = $(e.relatedTarget).closest(row);
if (!$wrapper.is($srcWrapper)) $wrapper.toggleClass('selected', addOrRemove);
};
const $document = $(document);
$document.on('focusin.topic-post', e => addSelected(e, true));
$document.on('focusout.topic-post', e => addSelected(e, false));
},
_moveSelection(direction) {
const $articles = this._findArticles();