-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathSearch.js
More file actions
47 lines (37 loc) · 1.12 KB
/
Search.js
File metadata and controls
47 lines (37 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import React from 'react';
import ReactTV from 'react-tv';
import { Focusable } from 'react-key-navigation'
export default class Search extends React.Component {
constructor() {
super();
this.state = {
active: false
};
}
onBlur() {
this.setState({active: false});
}
onFocus() {
this.setState({active: true});
}
onEnterDown(event, navigation) {
console.log('enter pressed');
navigation.forceFocus('sidebar');
}
onSupportedKeyDown(event, navigation) {
console.log('onSupportedKeyDown', event, navigation);
if(event === "space"){
this.onEnterDown(event, navigation);
}else if(event === "esc"){
console.log("esc was pressed");
navigation.focusDefault();
}
}
render() {
return (
<Focusable onFocus={() => this.onFocus()} onBlur={() => this.onBlur()} onEnterDown={(e, n) => this.onEnterDown(e, n)} onSupportedKeyDown={(e, n) => this.onSupportedKeyDown(e, n)} navDefault>
<div class={this.state.active ? 'search-box-placeholder-focus' : ''} id="search-box-placeholder"><i class="fa fa-search"></i></div>
</Focusable>
);
}
}