Skip to content

Commit 5967dc4

Browse files
authored
Merge pull request element-hq#2339 from vector-im/dbkr/directory_search_box
Directory search join button
2 parents be6fbc2 + bf58c34 commit 5967dc4

6 files changed

Lines changed: 112 additions & 17 deletions

File tree

‎src/components/structures/RoomDirectory.js‎

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ module.exports = React.createClass({
9898
},
9999

100100
getMoreRooms: function() {
101+
if (!MatrixClientPeg.get()) return q();
102+
101103
const my_filter_string = this.filterString;
102104
const opts = {limit: 20};
103105
if (this.nextBatch) opts.since = this.nextBatch;
@@ -212,9 +214,7 @@ module.exports = React.createClass({
212214
return this.getMoreRooms();
213215
},
214216

215-
onFilterChange: function(ev) {
216-
const alias = ev.target.value;
217-
217+
onFilterChange: function(alias) {
218218
this.filterString = alias || null;
219219

220220
// don't send the request for a little bit,
@@ -230,10 +230,18 @@ module.exports = React.createClass({
230230
}, 300);
231231
},
232232

233-
onFilterKeyUp: function(ev) {
234-
if (ev.key == "Enter") {
235-
this.showRoomAlias(ev.target.value);
233+
onFilterClear: function() {
234+
this.filterString = null;
235+
236+
if (this.filterTimeout) {
237+
clearTimeout(this.filterTimeout);
236238
}
239+
// update immediately
240+
this.refreshRoomList();
241+
},
242+
243+
onJoinClick: function(alias) {
244+
this.showRoomAlias(alias);
237245
},
238246

239247
showRoomAlias: function(alias) {
@@ -393,13 +401,15 @@ module.exports = React.createClass({
393401

394402
const SimpleRoomHeader = sdk.getComponent('rooms.SimpleRoomHeader');
395403
const NetworkDropdown = sdk.getComponent('directory.NetworkDropdown');
404+
const DirectorySearchBox = sdk.getComponent('elements.DirectorySearchBox');
396405
return (
397406
<div className="mx_RoomDirectory">
398407
<SimpleRoomHeader title="Directory" />
399408
<div className="mx_RoomDirectory_list">
400409
<div className="mx_RoomDirectory_listheader">
401-
<input type="text" placeholder="Find a room by keyword or room ID (#foo:matrix.org)"
402-
className="mx_RoomDirectory_input" size="64" onChange={this.onFilterChange} onKeyUp={this.onFilterKeyUp}
410+
<DirectorySearchBox
411+
className="mx_RoomDirectory_searchbox"
412+
onChange={this.onFilterChange} onClear={this.onFilterClear} onJoinClick={this.onJoinClick}
403413
/>
404414
<NetworkDropdown config={this.props.config} onNetworkChange={this.onNetworkChange} />
405415
</div>
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
Copyright 2016 OpenMarket Ltd
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
.mx_DirectorySearchBox {
18+
position: relative;
19+
border-radius: 3px;
20+
border: 1px solid #c7c7c7;
21+
}
22+
23+
.mx_DirectorySearchBox_container {
24+
display: flex;
25+
display: -webkit-flex;
26+
padding-left: 9px;
27+
padding-right: 9px;
28+
}
29+
30+
.mx_DirectorySearchBox_input {
31+
flex-grow: 1;
32+
-webkit-flex-grow: 1;
33+
border: 0;
34+
padding: 0;
35+
font-weight: 300;
36+
font-size: 13px;
37+
}
38+
input[type=text].mx_DirectorySearchBox_input:focus {
39+
border: 0;
40+
}
41+
42+
.mx_DirectorySearchBox_joinButton {
43+
display: table-cell;
44+
padding: 3px;
45+
padding-left: 10px;
46+
padding-right: 10px;
47+
background-color: #efefef;
48+
border-radius: 3px;
49+
background-image: url('img/icon-return.svg');
50+
background-position: 8px 70%;
51+
background-repeat: no-repeat;
52+
text-indent: 18px;
53+
font-weight: 600;
54+
font-size: 12px;
55+
user-select: none;
56+
cursor: pointer;
57+
}
58+
59+
.mx_DirectorySearchBox_clear_wrapper {
60+
display: table-cell;
61+
}
62+
63+
.mx_DirectorySearchBox_clear {
64+
display: inline-block;
65+
vertical-align: middle;
66+
background: url('img/icon_context_delete.svg');
67+
background-position: 0 50%;
68+
background-repeat: no-repeat;
69+
width: 15px;
70+
height: 15px;
71+
cursor: pointer;
72+
}

‎src/skins/vector/css/vector-web/structures/RoomDirectory.css‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,20 @@ limitations under the License.
5353

5454
.mx_RoomDirectory_listheader {
5555
display: table;
56+
table-layout: fixed;
5657
width: 100%;
5758
margin-top: 12px;
5859
margin-bottom: 12px;
5960
border-spacing: 5px;
6061
}
6162

62-
.mx_RoomDirectory_input {
63+
.mx_RoomDirectory_searchbox {
6364
display: table-cell;
64-
border-radius: 3px;
65-
border: 1px solid #c7c7c7;
66-
font-weight: 300;
67-
font-size: 13px;
68-
padding: 9px;
6965
}
7066

7167
.mx_RoomDirectory_listheader .mx_NetworkDropdown {
7268
display: table-cell;
73-
width: 100%;
69+
width: 200px;
7470
}
7571

7672
.mx_RoomDirectory_tableWrapper {

‎src/skins/vector/css/vector-web/views/directory/NetworkDropdown.css‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ limitations under the License.
2424
border: 1px solid #c7c7c7;
2525
font-weight: 300;
2626
font-size: 13px;
27-
margin-top: 12px;
28-
margin-bottom: 12px;
2927
user-select: none;
3028
}
3129

Lines changed: 18 additions & 0 deletions
Loading

‎test/app-tests/joining.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ describe('joining a room', function () {
102102
var input = ReactTestUtils.findRenderedDOMComponentWithTag(
103103
roomDir, 'input');
104104
input.value = ROOM_ALIAS;
105+
ReactTestUtils.Simulate.change(input);
105106
ReactTestUtils.Simulate.keyUp(input, {key: 'Enter'});
106107

107108
// that should create a roomview which will start a peek; wait

0 commit comments

Comments
 (0)