Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit be00320

Browse files
committed
Make use of the KeyBindingsManager in the ScrollPanel
Signed-off-by: Clemens Zeidler <[email protected]>
1 parent 57cd8af commit be00320

File tree

2 files changed

+12
-21
lines changed

2 files changed

+12
-21
lines changed

src/components/structures/LoggedInView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ class LoggedInView extends React.Component<IProps, IState> {
444444
case RoomAction.RoomScrollDown:
445445
case RoomAction.JumpToFirstMessage:
446446
case RoomAction.JumpToLatestMessage:
447+
// pass the event down to the scroll panel
447448
this._onScrollKeyPressed(ev);
448449
handled = true;
449450
break;

src/components/structures/ScrollPanel.js

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ limitations under the License.
1616

1717
import React, {createRef} from "react";
1818
import PropTypes from 'prop-types';
19-
import { Key } from '../../Keyboard';
2019
import Timer from '../../utils/Timer';
2120
import AutoHideScrollbar from "./AutoHideScrollbar";
2221
import {replaceableComponent} from "../../utils/replaceableComponent";
22+
import {getKeyBindingsManager, RoomAction} from "../../KeyBindingsManager";
2323

2424
const DEBUG_SCROLL = false;
2525

@@ -535,29 +535,19 @@ export default class ScrollPanel extends React.Component {
535535
* @param {object} ev the keyboard event
536536
*/
537537
handleScrollKey = ev => {
538-
switch (ev.key) {
539-
case Key.PAGE_UP:
540-
if (!ev.ctrlKey && !ev.shiftKey && !ev.altKey && !ev.metaKey) {
541-
this.scrollRelative(-1);
542-
}
538+
const roomAction = getKeyBindingsManager().getRoomAction(ev);
539+
switch (roomAction) {
540+
case RoomAction.ScrollUp:
541+
this.scrollRelative(-1);
543542
break;
544-
545-
case Key.PAGE_DOWN:
546-
if (!ev.ctrlKey && !ev.shiftKey && !ev.altKey && !ev.metaKey) {
547-
this.scrollRelative(1);
548-
}
543+
case RoomAction.RoomScrollDown:
544+
this.scrollRelative(1);
549545
break;
550-
551-
case Key.HOME:
552-
if (ev.ctrlKey && !ev.shiftKey && !ev.altKey && !ev.metaKey) {
553-
this.scrollToTop();
554-
}
546+
case RoomAction.JumpToFirstMessage:
547+
this.scrollToTop();
555548
break;
556-
557-
case Key.END:
558-
if (ev.ctrlKey && !ev.shiftKey && !ev.altKey && !ev.metaKey) {
559-
this.scrollToBottom();
560-
}
549+
case RoomAction.JumpToLatestMessage:
550+
this.scrollToBottom();
561551
break;
562552
}
563553
};

0 commit comments

Comments
 (0)