Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…dropdown-tree-select into developTemp
  • Loading branch information
Magnus Ellinge committed Apr 3, 2019
2 parents 7f6cf98 + 4e92fff commit bb4fdb1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/index.js
Expand Up @@ -201,7 +201,8 @@ class DropdownTreeSelect extends Component {
}

onKeyboardKeyDown = e => {
if (!this.props.enableKeyboardNavigation) { return }
const { enableKeyboardNavigation, readOnly } = this.props
if (!enableKeyboardNavigation) { return }

const { showDropdown, tags, searchModeOn, currentFocus } = this.state

Expand All @@ -213,7 +214,7 @@ class DropdownTreeSelect extends Component {
} else if (showDropdown && keyboardNavigation.isValidKey(e.key, true)) {
const tm = this.treeManager
const tree = searchModeOn ? tm.matchTree : tm.tree
const newFocus = tm.handleNavigationKey(currentFocus, tree, e.key, !searchModeOn, this.onCheckboxChange, this.onNodeToggle)
const newFocus = tm.handleNavigationKey(currentFocus, tree, e.key, readOnly, !searchModeOn, this.onCheckboxChange, this.onNodeToggle)
if (newFocus !== currentFocus) {
this.setState({ currentFocus: newFocus })
}
Expand Down
4 changes: 2 additions & 2 deletions src/tree-manager/index.js
Expand Up @@ -246,15 +246,15 @@ class TreeManager {
})
}

handleNavigationKey(currentFocus, tree, key, markSubTreeOnNonExpanded, onToggleChecked, onToggleExpanded) {
handleNavigationKey(currentFocus, tree, key, readOnly, markSubTreeOnNonExpanded, onToggleChecked, onToggleExpanded) {
const prevFocus = currentFocus && this.getNodeById(currentFocus)
const action = keyboardNavigation.getAction(prevFocus, key)

if (FocusActionNames.has(action)) {
const newFocus = this.handleFocusNavigationkey(tree, action, prevFocus, markSubTreeOnNonExpanded)
return newFocus
}
if (action === NavActions.ToggleChecked && prevFocus) {
if (action === NavActions.ToggleChecked && prevFocus && !readOnly && !(prevFocus.readOnly || prevFocus.disabled)) {
onToggleChecked(prevFocus._id, prevFocus.checked !== true)
}
if (action === NavActions.ToggleExpanded && prevFocus) {
Expand Down

0 comments on commit bb4fdb1

Please sign in to comment.