Scrollable Accounts list // Tab;Enter;Keydown for first input #3396

This commit is contained in:
Nicolas Gotchac 2016-11-14 15:35:25 +01:00
parent d1848117ef
commit ecb89d3670
2 changed files with 31 additions and 0 deletions

View File

@ -21,3 +21,7 @@
.iconMenu option { .iconMenu option {
padding-left: 30px; padding-left: 30px;
} }
.menu {
display: none;
}

View File

@ -15,6 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
import React, { Component, PropTypes } from 'react'; import React, { Component, PropTypes } from 'react';
import keycode from 'keycode';
import { MenuItem, AutoComplete as MUIAutoComplete } from 'material-ui'; import { MenuItem, AutoComplete as MUIAutoComplete } from 'material-ui';
import { PopoverAnimationVertical } from 'material-ui/Popover'; import { PopoverAnimationVertical } from 'material-ui/Popover';
@ -67,6 +68,9 @@ export default class AutoComplete extends Component {
fullWidth fullWidth
floatingLabelFixed floatingLabelFixed
dataSource={ this.getDataSource() } dataSource={ this.getDataSource() }
menuProps={ { maxHeight: 400 } }
ref='muiAutocomplete'
onKeyDown={ this.onKeyDown }
/> />
); );
} }
@ -91,6 +95,29 @@ export default class AutoComplete extends Component {
})); }));
} }
onKeyDown = (event) => {
const { muiAutocomplete } = this.refs;
switch (keycode(event)) {
case 'down':
const { menu } = muiAutocomplete.refs;
menu.handleKeyDown(event);
break;
case 'enter':
case 'tab':
event.preventDefault();
event.stopPropagation();
event.which = 'useless';
const e = new CustomEvent('down');
e.which = 40;
muiAutocomplete.handleKeyDown(e);
break;
}
}
onChange = (item, idx) => { onChange = (item, idx) => {
if (idx === -1) { if (idx === -1) {
return; return;