mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-22 14:58:16 +00:00
[Glitch] Don't reset scroll when using hotkeys to focus columns, add hotkey 0 to scroll to top
Port 9334bd9ede to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
@@ -81,7 +81,7 @@ import {
|
||||
Quotes,
|
||||
} from './util/async-components';
|
||||
import { ColumnsContextProvider } from './util/columns_context';
|
||||
import { focusColumn, getFocusedItemIndex, focusItemSibling } from './util/focusUtils';
|
||||
import { focusColumn, getFocusedItemIndex, focusItemSibling, focusFirstItem } from './util/focusUtils';
|
||||
import { WrappedSwitch, WrappedRoute } from './util/react_router_helpers';
|
||||
|
||||
// Dummy import, to make sure that <Status /> ends up in the application bundle.
|
||||
@@ -495,20 +495,21 @@ class UI extends PureComponent {
|
||||
};
|
||||
|
||||
handleHotkeyFocusColumn = e => {
|
||||
focusColumn({index: e.key * 1});
|
||||
focusColumn(e.key * 1);
|
||||
};
|
||||
|
||||
handleHotkeyLoadMore = () => {
|
||||
document.querySelector('.load-more')?.focus();
|
||||
};
|
||||
|
||||
handleMoveToTop = () => {
|
||||
focusFirstItem();
|
||||
};
|
||||
|
||||
handleMoveUp = () => {
|
||||
const currentItemIndex = getFocusedItemIndex();
|
||||
if (currentItemIndex === -1) {
|
||||
focusColumn({
|
||||
index: 1,
|
||||
focusItem: 'first-visible',
|
||||
});
|
||||
focusColumn(1);
|
||||
} else {
|
||||
focusItemSibling(currentItemIndex, -1);
|
||||
}
|
||||
@@ -517,10 +518,7 @@ class UI extends PureComponent {
|
||||
handleMoveDown = () => {
|
||||
const currentItemIndex = getFocusedItemIndex();
|
||||
if (currentItemIndex === -1) {
|
||||
focusColumn({
|
||||
index: 1,
|
||||
focusItem: 'first-visible',
|
||||
});
|
||||
focusColumn(1);
|
||||
} else {
|
||||
focusItemSibling(currentItemIndex, 1);
|
||||
}
|
||||
@@ -615,6 +613,7 @@ class UI extends PureComponent {
|
||||
focusLoadMore: this.handleHotkeyLoadMore,
|
||||
moveDown: this.handleMoveDown,
|
||||
moveUp: this.handleMoveUp,
|
||||
moveToTop: this.handleMoveToTop,
|
||||
back: this.handleHotkeyBack,
|
||||
goToHome: this.handleHotkeyGoToHome,
|
||||
goToNotifications: this.handleHotkeyGoToNotifications,
|
||||
|
||||
Reference in New Issue
Block a user