bbc / lrud

Left, Right, Up, Down. A spatial navigation library for devices with input via directional controls.
Apache License 2.0
94 stars 21 forks source link

Uncaught RangeError: Maximum call stack size exceeded #79

Closed adrian-wozniak closed 3 years ago

adrian-wozniak commented 3 years ago

Describe the bug If the navigation tree has node with id 'undefined' (string containing 9 chars word) then climbUp method fails with Maximum call stack size exceeded when no focus candidates found.

When the root node is reached than climbing should stop but apparently it jumps (climbs up) to node with id 'undefined', and continue climbing, until root node is reached again, and again, and again, until call stack size is exceeded.

To Reproduce

const navigation= new Lrud()

navigation.registerNode('root', { orientation: 'horizontal' })
navigation.registerNode('undefined', { parent: 'root', isFocusable: true })

navigation.assignFocus('undefined')

navigation.handleKeyEvent({ direction: 'right' });

Expected behavior Handling key event should be stopped and currently focused node should stay focused.

Additional context On more complicated navigation trees it may happen than, before exceeding call stack size, focus suddenly jumps to node with id 'undefined'. Similar issue is for node with id 'null'. Additional side effects of this bug: