Skip to content

Commit

Permalink
PLAT-110783: Fix spotlight to trigger onLeaveContainerFail when leave…
Browse files Browse the repository at this point in the history
…For is configured (#2791)

* fix container target selection to return null when leaveFor is configured

Signed-off-by: Ryan Duffy <[email protected]>

* change log

Signed-off-by: Ryan Duffy <[email protected]>

* fix change log

Signed-off-by: Ryan Duffy <[email protected]>
  • Loading branch information
Ryan Duffy authored Jun 16, 2020
1 parent 68f8d2e commit d4e3d22
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/spotlight/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

The following is a curated list of changes in the Enact spotlight module, newest changes on the top.

## [unreleased]

### Fixed

- `spotlight` to trigger `onLeaveContainerFail` when `leaveFor` prevents navigation

## [3.3.0-alpha.12] - 2020-06-15

No significant changes.
Expand Down
6 changes: 5 additions & 1 deletion packages/spotlight/src/target.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ function getTargetByDirectionFromElement (direction, element) {

const elementRect = getRect(element);

return getNavigableContainersForNode(element)
const next = getNavigableContainersForNode(element)
.reduceRight((result, containerId, index, elementContainerIds) => {
result = result || getTargetInContainerByDirectionFromElement(
direction,
Expand All @@ -380,6 +380,10 @@ function getTargetByDirectionFromElement (direction, element) {

return result;
}, null);

// if the reduce above returns the original element, it means it hit a `leaveFor` config that
// prevents navigation so we enforce that here by returning null.
return next !== element ? next : null;
}

function getTargetByDirectionFromPosition (direction, position, containerId) {
Expand Down

0 comments on commit d4e3d22

Please sign in to comment.