bbc / lrud

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

Change `setActiveChild` to no longer recurse up the tree #44

Closed edmorrish closed 5 years ago

edmorrish commented 5 years ago

Description

THIS IS A BREAKING CHANGE REQUIRING A MAJOR VERSION

Modifies the behaviour of setActiveChild so that it now only sets the active child of the targeted element, previously it would follow the parent path up and set the active child of every parent element all the way up to the top, resulting in problems with element focus. This behaviour seems more intuitive given that the function name specifies nothing about its recursive behaviour.

Motivation and Context

When changing a part of the tree that is not in the main focus part we need to be able to change active children without resetting the focus state, for example: to make a newly focusable button the first indexed child on its row. This was previously impossible as changing the active child would propagate changes up the tree. Resolves: https://github.com/bbc/lrud/issues/40

How Has This Been Tested?

Automated + manual tests

Types of changes

Checklist:

jordanholt commented 5 years ago

Would like to get other horses opinions on #40 before we settle on this approach 🐴