sforkowany z mirror/soapbox
FilterBar: remove handleKeyDown
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>party-hat
rodzic
5e31c12063
commit
90a55f2626
|
@ -20,7 +20,6 @@ export default class FilterBar extends React.PureComponent {
|
|||
};
|
||||
|
||||
componentDidMount() {
|
||||
document.addEventListener('keydown', this.handleKeyDown, false);
|
||||
window.addEventListener('resize', this.handleResize, { passive: true });
|
||||
|
||||
const { left, width } = this.getActiveTabIndicationSize();
|
||||
|
@ -28,7 +27,6 @@ export default class FilterBar extends React.PureComponent {
|
|||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
document.removeEventListener('keydown', this.handleKeyDown, false);
|
||||
document.removeEventListener('resize', this.handleResize, false);
|
||||
}
|
||||
|
||||
|
@ -52,27 +50,6 @@ export default class FilterBar extends React.PureComponent {
|
|||
this.focusedItem = c;
|
||||
}
|
||||
|
||||
handleKeyDown = e => {
|
||||
const items = Array.from(this.node.getElementsByTagName('a'));
|
||||
const index = items.indexOf(document.activeElement);
|
||||
let element = null;
|
||||
|
||||
switch(e.key) {
|
||||
case 'ArrowRight':
|
||||
element = items[index+1] || items[0];
|
||||
break;
|
||||
case 'ArrowLeft':
|
||||
element = items[index-1] || items[items.length-1];
|
||||
break;
|
||||
}
|
||||
|
||||
if (element) {
|
||||
element.focus();
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
handleItemKeyPress = e => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
this.handleClick(e);
|
||||
|
|
Ładowanie…
Reference in New Issue