@enact/spotlight 5.4.1 → 5.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  The following is a curated list of changes in the Enact spotlight module, newest changes on the top.
4
4
 
5
+ ## [5.4.3] - 2026-02-26
6
+
7
+ ### Fixed
8
+
9
+ - `spotlight` to revert 5.4.0 fix to skip visibility check when entering a restricted container or choose a visible container as next target
10
+ - `spotlight` to focus visible children of elements which do not have `overflow:true`
11
+
12
+ ## [5.4.2] - 2026-01-28
13
+
14
+ No significant changes.
15
+
5
16
  ## [5.4.1] - 2025-12-30
6
17
 
7
18
  No significant changes.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enact/spotlight",
3
- "version": "5.4.1",
3
+ "version": "5.4.3",
4
4
  "description": "A focus management library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,12 +25,12 @@
25
25
  }
26
26
  },
27
27
  "dependencies": {
28
- "@enact/core": "^5.4.1",
28
+ "@enact/core": "^5.4.3",
29
29
  "classnames": "^2.5.1",
30
30
  "prop-types": "^15.8.1",
31
31
  "ramda": "^0.32.0",
32
- "react": "^19.2.3",
33
- "react-dom": "^19.2.3",
32
+ "react": "^19.2.4",
33
+ "react-dom": "^19.2.4",
34
34
  "warning": "^4.0.3"
35
35
  }
36
36
  }
package/src/target.js CHANGED
@@ -198,7 +198,7 @@ function getTargetInContainerByDirectionFromPosition(direction, containerId, pos
198
198
  if (next && containerId !== nextCandidateContainerId) {
199
199
  // Don't apply visibility check when entering a restricted container. The container's own enterTo logic (last-focused, default-element) handles entry
200
200
  // OR verify if the element from another container is visible (only for non-restricted)
201
- if (isRestrictedContainer(nextCandidateContainerId) || isElementVisibleInContainer(next, nextCandidateContainerId)) {
201
+ if (isRestrictedContainer(nextCandidateContainerId) || isElementVisibleInContainer(next, nextCandidateContainerId) || isElementVisibleInViewport(next, nextCandidateContainerId)) {
202
202
  return {
203
203
  v: next
204
204
  };
@@ -206,7 +206,7 @@ function getTargetInContainerByDirectionFromPosition(direction, containerId, pos
206
206
  // otherwise, try to navigate to an element that is visible in its container
207
207
  next = (0, _navigate["default"])(positionRect, direction, elementRects.filter(function (rect) {
208
208
  var elementContainerId = (0, _container.getContainersForNode)(rect.element).pop();
209
- return isElementVisibleInContainer(rect.element, elementContainerId);
209
+ return isElementVisibleInContainer(rect.element, elementContainerId) || isElementVisibleInViewport(rect.element, elementContainerId);
210
210
  }), (0, _container.getContainerConfig)(containerId));
211
211
  }
212
212
  }
@@ -305,7 +305,7 @@ function getTargetInContainerByDirectionFromElement(direction, containerId, elem
305
305
  if (next && containerId !== nextCandidateContainerId) {
306
306
  // Don't apply visibility check when entering a restricted container. The container's own enterTo logic (last-focused, default-element) handles entry
307
307
  // OR verify if the element from another container is visible
308
- if (isRestrictedContainer(nextCandidateContainerId) || isElementVisibleInContainer(next, nextCandidateContainerId)) {
308
+ if (isRestrictedContainer(nextCandidateContainerId) || isElementVisibleInContainer(next, nextCandidateContainerId) || isElementVisibleInViewport(next, nextCandidateContainerId)) {
309
309
  return {
310
310
  v: next
311
311
  };
@@ -313,7 +313,7 @@ function getTargetInContainerByDirectionFromElement(direction, containerId, elem
313
313
  // otherwise, try to navigate to an element that is visible in its container
314
314
  next = (0, _navigate["default"])(elementRect, direction, elementRects.filter(function (rect) {
315
315
  var elementContainerId = (0, _container.getContainersForNode)(rect.element).pop();
316
- return isElementVisibleInContainer(rect.element, elementContainerId);
316
+ return isElementVisibleInContainer(rect.element, elementContainerId) || isElementVisibleInViewport(rect.element, elementContainerId);
317
317
  }), (0, _container.getContainerConfig)(containerId), partitionRect);
318
318
  }
319
319
  }
@@ -425,6 +425,20 @@ function isElementVisibleInContainer(element, containerId) {
425
425
  var isHorizontallyVisible = elementRight >= containerLeft && elementLeft <= containerRight;
426
426
  return isVerticallyVisible && isHorizontallyVisible;
427
427
  }
428
+ function isElementVisibleInViewport(element, containerId) {
429
+ // If the element's spotlight container has overflow:true, that container is the authority
430
+ // on what's visible (e.g., a Scroller hiding scrolled-away items).
431
+ var config = (0, _container.getContainerConfig)(containerId);
432
+ if (config && config.overflow) {
433
+ return false;
434
+ }
435
+ var _element$getBoundingC2 = element.getBoundingClientRect(),
436
+ top = _element$getBoundingC2.top,
437
+ right = _element$getBoundingC2.right,
438
+ bottom = _element$getBoundingC2.bottom,
439
+ left = _element$getBoundingC2.left;
440
+ return bottom > 0 && right > 0 && top < window.innerHeight && left < window.innerWidth;
441
+ }
428
442
  var getOffsetDistanceToTargetFromPosition = function getOffsetDistanceToTargetFromPosition(distance, direction, _ref, _ref2) {
429
443
  var x = _ref.x,
430
444
  y = _ref.y;