mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 03:12:46 +08:00
UX: Make the .selected class follow focus
This commit is contained in:
parent
3212cdda78
commit
59b7760e2e
|
@ -89,6 +89,8 @@ export default {
|
||||||
this._bindToClick(binding.click, key);
|
this._bindToClick(binding.click, key);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this._bindFocus();
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleBookmark() {
|
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) {
|
_moveSelection(direction) {
|
||||||
const $articles = this._findArticles();
|
const $articles = this._findArticles();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user