Only focus first item of dropdown if it was opened via keyboard

This commit is contained in:
Thibaut Girka
2018-09-11 22:35:17 +02:00
committed by ThibG
parent cf142e8556
commit 5ff733b614
4 changed files with 19 additions and 11 deletions

View File

@ -8,10 +8,11 @@ const mapStateToProps = state => ({
isModalOpen: state.get('modal').modalType === 'ACTIONS',
dropdownPlacement: state.getIn(['dropdown_menu', 'placement']),
openDropdownId: state.getIn(['dropdown_menu', 'openId']),
openedViaKeyboard: state.getIn(['dropdown_menu', 'keyboard']),
});
const mapDispatchToProps = (dispatch, { status, items }) => ({
onOpen(id, onItemClick, dropdownPlacement) {
onOpen(id, onItemClick, dropdownPlacement, keyboard) {
dispatch(isUserTouching() ? openModal('ACTIONS', {
status,
actions: items.map(
@ -21,7 +22,7 @@ const mapDispatchToProps = (dispatch, { status, items }) => ({
onClick: item.action ? ((e) => { return onItemClick(i, e) }) : null,
} : null
),
}) : openDropdownMenu(id, dropdownPlacement));
}) : openDropdownMenu(id, dropdownPlacement, keyboard));
},
onClose(id) {
dispatch(closeModal());