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

Commit 39816f6

Browse files
authored
Fix Shortcut prompt for Search showing in minimized Roomlist (#9014)
1 parent 4844cc1 commit 39816f6

File tree

4 files changed

+41
-80
lines changed

4 files changed

+41
-80
lines changed

res/css/structures/_LeftPanel.scss

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -122,38 +122,6 @@ $roomListCollapsedWidth: 68px;
122122
margin-top: 12px;
123123
}
124124

125-
.mx_RoomSearch_shortcutPrompt {
126-
border-radius: 6px;
127-
background-color: $panel-actions;
128-
padding: 2px 4px;
129-
user-select: none;
130-
font-size: $font-12px;
131-
line-height: $font-15px;
132-
font-weight: $font-semi-bold;
133-
color: $light-fg-color;
134-
margin-right: 6px;
135-
}
136-
137-
.mx_RoomSearch_focused, .mx_RoomSearch_hasQuery {
138-
.mx_RoomSearch_shortcutPrompt {
139-
display: none;
140-
}
141-
142-
& + .mx_LeftPanel_exploreButton,
143-
& + .mx_LeftPanel_recentsButton {
144-
// Cheaty way to return the occupied space to the filter input
145-
flex-basis: 0;
146-
margin: 0;
147-
width: 0;
148-
149-
// Don't forget to hide the masked ::before icon,
150-
// using display:none or visibility:hidden would break accessibility
151-
&::before {
152-
content: none;
153-
}
154-
}
155-
}
156-
157125
.mx_LeftPanel_dialPadButton {
158126
width: 32px;
159127
height: 32px;

res/css/structures/_RoomSearch.scss

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
// Note: this component expects to be contained within a flexbox
1818
.mx_RoomSearch {
1919
flex: 1;
20+
min-width: 0;
2021
border-radius: 8px;
2122
background-color: $panel-actions;
2223
// keep border thickness consistent to prevent movement
@@ -28,6 +29,8 @@ limitations under the License.
2829
display: flex;
2930
align-items: center;
3031

32+
cursor: pointer;
33+
3134
.mx_RoomSearch_icon {
3235
width: 16px;
3336
height: 16px;
@@ -36,11 +39,35 @@ limitations under the License.
3639
background-color: $secondary-content;
3740
margin-left: 7px;
3841
margin-bottom: 2px;
42+
flex-shrink: 0;
3943
}
4044

4145
.mx_RoomSearch_spotlightTriggerText {
4246
font-size: $font-12px;
4347
line-height: $font-16px;
48+
color: $tertiary-content;
49+
flex: 1;
50+
min-width: 0;
51+
// the following rules are to match that of a real input field
52+
overflow: hidden;
53+
margin: 9px;
54+
font-weight: $font-semi-bold;
55+
}
56+
57+
.mx_RoomSearch_shortcutPrompt {
58+
border-radius: 6px;
59+
background-color: $panel-actions;
60+
padding: 2px 4px;
61+
user-select: none;
62+
font-size: $font-12px;
63+
line-height: $font-15px;
64+
font-family: inherit;
65+
font-weight: $font-semi-bold;
66+
color: $light-fg-color;
67+
margin-right: 6px;
68+
white-space: nowrap;
69+
overflow: hidden;
70+
text-overflow: ellipsis;
4471
}
4572

4673
&.mx_RoomSearch_minimized {
@@ -55,44 +82,25 @@ limitations under the License.
5582
align-self: center;
5683
}
5784

58-
&:hover {
59-
background-color: $tertiary-content;
60-
61-
.mx_RoomSearch_icon {
62-
background-color: $background;
63-
}
85+
.mx_RoomSearch_shortcutPrompt {
86+
display: none;
6487
}
6588
}
6689

67-
&.mx_RoomSearch_spotlightTrigger {
68-
cursor: pointer;
69-
min-width: 0;
90+
&:hover {
91+
background-color: $tertiary-content;
7092

7193
.mx_RoomSearch_spotlightTriggerText {
72-
color: $tertiary-content;
73-
flex: 1;
74-
min-width: 0;
75-
// the following rules are to match that of a real input field
76-
overflow: hidden;
77-
margin: 9px;
78-
font-weight: $font-semi-bold;
94+
color: $background;
7995
}
8096

81-
&:hover {
82-
background-color: $tertiary-content;
83-
84-
.mx_RoomSearch_spotlightTriggerText {
85-
color: $background;
86-
}
87-
88-
.mx_RoomSearch_shortcutPrompt {
89-
background-color: $background;
90-
color: $secondary-content;
91-
}
97+
.mx_RoomSearch_shortcutPrompt {
98+
background-color: $background;
99+
color: $secondary-content;
100+
}
92101

93-
.mx_RoomSearch_icon {
94-
background-color: $background;
95-
}
102+
.mx_RoomSearch_icon {
103+
background-color: $background;
96104
}
97105
}
98106
}

src/components/structures/LeftPanel.tsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,6 @@ export default class LeftPanel extends React.Component<IProps, IState> {
304304
}
305305
};
306306

307-
private selectRoom = () => {
308-
const firstRoom = this.listContainerRef.current.querySelector<HTMLDivElement>(".mx_RoomTile");
309-
if (firstRoom) {
310-
firstRoom.click();
311-
return true; // to get the field to clear
312-
}
313-
};
314-
315307
private renderBreadcrumbs(): React.ReactNode {
316308
if (this.state.showBreadcrumbs === BreadcrumbsMode.Legacy && !this.props.isMinimized) {
317309
return (
@@ -357,10 +349,7 @@ export default class LeftPanel extends React.Component<IProps, IState> {
357349
onBlur={this.onBlur}
358350
onKeyDown={this.onKeyDown}
359351
>
360-
<RoomSearch
361-
isMinimized={this.props.isMinimized}
362-
onSelectRoom={this.selectRoom}
363-
/>
352+
<RoomSearch isMinimized={this.props.isMinimized} />
364353

365354
{ dialPadButton }
366355
{ rightButton }

src/components/structures/RoomSearch.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ import AccessibleButton from "../views/elements/AccessibleButton";
2828

2929
interface IProps {
3030
isMinimized: boolean;
31-
/**
32-
* @returns true if a room has been selected and the search field should be cleared
33-
*/
34-
onSelectRoom(): boolean;
3531
}
3632

3733
export default class RoomSearch extends React.PureComponent<IProps> {
@@ -67,9 +63,9 @@ export default class RoomSearch extends React.PureComponent<IProps> {
6763
<div className="mx_RoomSearch_icon" />
6864
);
6965

70-
const shortcutPrompt = <div className="mx_RoomSearch_shortcutPrompt">
66+
const shortcutPrompt = <kbd className="mx_RoomSearch_shortcutPrompt">
7167
{ IS_MAC ? "⌘ K" : _t(ALTERNATE_KEY_NAME[Key.CONTROL]) + " K" }
72-
</div>;
68+
</kbd>;
7369

7470
return <AccessibleButton onClick={this.openSpotlight} className={classes}>
7571
{ icon }

0 commit comments

Comments
 (0)