Skip to content

Commit

Permalink
fix(frontend/presenter): fix next line hotkey when navigator is closed (
Browse files Browse the repository at this point in the history
#601)

Bug introduced during #451, where the checks are too stringent.
  • Loading branch information
Harjot1Singh authored Oct 15, 2020
1 parent 1e9fb85 commit 54b1640
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/frontend/src/shared/NavigatorHotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,21 @@ const NavigatorHotKeys = ( { active, children, mouseTargetRef } ) => {
}
}, [ lines, lineId ] )

const goNextLine = useCallback( ( { target: { className: targetClass, parentNode } } ) => {
const goNextLine = useCallback( ( {
target: { nodeName, className: targetClass, parentNode },
} ) => {
const { current: mouseTarget } = mouseTargetRef

/* Near the bottom of the screen the targetClass
becomes 'controller-container` instead of presenter.
In this case, we check the targetClass or its parent node's class
(which if the target is controller container, will be presenter) */
if ( !lines || ![ targetClass, parentNode.className ].includes( mouseTarget.className ) ) return
if (
// No lines
!lines
// Or a hotkey didn't trigger it, and another active element was clicked on
|| ( nodeName !== 'BODY' && ![ targetClass, parentNode.className ].includes( mouseTarget.className ) )
) return

const currentLineIndex = findLineIndex( lines, lineId )
const { id } = lines[ currentLineIndex ] || {}
Expand Down

0 comments on commit 54b1640

Please sign in to comment.