Skip to content

Commit

Permalink
fix: Code smell
Browse files Browse the repository at this point in the history
  • Loading branch information
ellinge committed Apr 5, 2019
1 parent 5f7d4d4 commit 866b3ec
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/tree-manager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,12 @@ class TreeManager {
return newFocus
}

return this.handleToggleNavigationkey(tree, action, currentFocus, readOnly, onToggleChecked, onToggleExpanded)
if (!prevFocus || !tree.has(prevFocus._id)) {
// No current focus or not visible
return currentFocus
}

return this.handleToggleNavigationkey(action, prevFocus, readOnly, onToggleChecked, onToggleExpanded)
}

handleFocusNavigationkey(tree, action, prevFocus, markSubTreeOnNonExpanded) {
Expand All @@ -254,12 +259,7 @@ class TreeManager {
return prevFocus && prevFocus._id
}

handleToggleNavigationkey(tree, action, currentFocus, readOnly, onToggleChecked, onToggleExpanded) {
const prevFocus = currentFocus && this.getNodeById(currentFocus)
if (!prevFocus || !tree.has(prevFocus._id)) {
// No current focus or not visible
return currentFocus
}
handleToggleNavigationkey = (action, prevFocus, readOnly, onToggleChecked, onToggleExpanded) => {
if (action === NavActions.ToggleChecked && !readOnly && !(prevFocus.readOnly || prevFocus.disabled)) {
onToggleChecked(prevFocus._id, prevFocus.checked !== true)
} else if (action === NavActions.ToggleExpanded) {
Expand Down

0 comments on commit 866b3ec

Please sign in to comment.