diff --git a/app/javascript/mastodon/components/status.js b/app/javascript/mastodon/components/status.js index f0f42eaa89..5471c52f7c 100644 --- a/app/javascript/mastodon/components/status.js +++ b/app/javascript/mastodon/components/status.js @@ -181,7 +181,7 @@ export default class Status extends ImmutablePureComponent { if (!isIntersecting && isHidden) { return ( -
+
{status.getIn(['account', 'display_name']) || status.getIn(['account', 'username'])} {status.get('content')}
@@ -198,7 +198,7 @@ export default class Status extends ImmutablePureComponent { const displayNameHTML = { __html: emojify(escapeTextContentForBrowser(displayName)) }; return ( -
+
}} /> @@ -234,7 +234,7 @@ export default class Status extends ImmutablePureComponent { } return ( -
+
diff --git a/app/javascript/mastodon/components/status_list.js b/app/javascript/mastodon/components/status_list.js index 9406b5fb9f..d87fe3ea16 100644 --- a/app/javascript/mastodon/components/status_list.js +++ b/app/javascript/mastodon/components/status_list.js @@ -104,6 +104,32 @@ export default class StatusList extends ImmutablePureComponent { this.props.onScrollToBottom(); } + handleKeyDown = (e) => { + if (['PageDown', 'PageUp', 'End', 'Home'].includes(e.key)) { + const article = (() => { + switch (e.key) { + case 'PageDown': + return e.nativeEvent.path[0].nodeName === 'ARTICLE' && e.nativeEvent.path[0].nextElementSibling; + case 'PageUp': + return e.nativeEvent.path[0].nodeName === 'ARTICLE' && e.nativeEvent.path[0].previousElementSibling; + case 'End': + return this.node.querySelector('[role="feed"] > article:last-of-type'); + case 'Home': + return this.node.querySelector('[role="feed"] > article:first-of-type'); + default: + return null; + } + })(); + + + if (article) { + e.preventDefault(); + article.focus(); + article.scrollIntoView(); + } + } + } + render () { const { statusIds, scrollKey, trackScroll, shouldUpdateScroll, isLoading, hasMore, prepend, emptyMessage } = this.props; @@ -113,7 +139,7 @@ export default class StatusList extends ImmutablePureComponent { if (isLoading || statusIds.size > 0 || !emptyMessage) { scrollableArea = (
-
+
{prepend} {statusIds.map((statusId, index) => {