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

Commit 72407a3

Browse files
authored
Merge pull request #4954 from matrix-org/t3chguy/room-list/14409
Room List v2 Enter in the filter field should select the first result
2 parents a70e575 + d253c58 commit 72407a3

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/components/structures/LeftPanel2.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,14 @@ export default class LeftPanel2 extends React.Component<IProps, IState> {
274274
}
275275
};
276276

277+
private onEnter = () => {
278+
const firstRoom = this.listContainerRef.current.querySelector<HTMLDivElement>(".mx_RoomTile2");
279+
if (firstRoom) {
280+
firstRoom.click();
281+
this.onSearch(""); // clear the search field
282+
}
283+
};
284+
277285
private onMoveFocus = (up: boolean) => {
278286
let element = this.focusedElement;
279287

@@ -346,6 +354,7 @@ export default class LeftPanel2 extends React.Component<IProps, IState> {
346354
onQueryUpdate={this.onSearch}
347355
isMinimized={this.props.isMinimized}
348356
onVerticalArrow={this.onKeyDown}
357+
onEnter={this.onEnter}
349358
/>
350359
<AccessibleButton
351360
className="mx_LeftPanel2_exploreButton"

src/components/structures/RoomSearch.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ interface IProps {
3939
onQueryUpdate: (newQuery: string) => void;
4040
isMinimized: boolean;
4141
onVerticalArrow(ev: React.KeyboardEvent);
42+
onEnter(ev: React.KeyboardEvent);
4243
}
4344

4445
interface IState {
@@ -115,6 +116,8 @@ export default class RoomSearch extends React.PureComponent<IProps, IState> {
115116
defaultDispatcher.fire(Action.FocusComposer);
116117
} else if (ev.key === Key.ARROW_UP || ev.key === Key.ARROW_DOWN) {
117118
this.props.onVerticalArrow(ev);
119+
} else if (ev.key === Key.ENTER) {
120+
this.props.onEnter(ev);
118121
}
119122
};
120123

0 commit comments

Comments
 (0)