@enact/spotlight 5.2.0 → 5.2.1

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,12 @@
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.2.1] - 2025-09-02
6
+
7
+ ### Fixed
8
+
9
+ - `spotlight` to preserve the last focused element on component unmount
10
+
5
11
  ## [5.2.0] - 2025-08-08
6
12
 
7
13
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enact/spotlight",
3
- "version": "5.2.0",
3
+ "version": "5.2.1",
4
4
  "description": "A focus management library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,7 +25,7 @@
25
25
  }
26
26
  },
27
27
  "dependencies": {
28
- "@enact/core": "^5.2.0",
28
+ "@enact/core": "^5.2.1",
29
29
  "classnames": "^2.5.1",
30
30
  "prop-types": "^15.8.1",
31
31
  "ramda": "^0.31.3",
package/src/container.js CHANGED
@@ -380,14 +380,15 @@ var getSpottableDescendants = exports.getSpottableDescendants = function getSpot
380
380
  * Recursively get spottable descendants by including elements within sub-containers that do not
381
381
  * have `enterTo` configured or which are not hidden due to overflow
382
382
  *
383
- * @param {String} containerId ID of container
384
- * @param {String[]} [excludedContainers] IDs of containers to exclude from result set
383
+ * @param {String} containerId ID of container
384
+ * @param {String[]} [excludedContainers] IDs of containers to exclude from result set
385
+ * @param {Boolean} useLastFocusedElement Determines whether to use the last focused element
385
386
  *
386
- * @returns {Node[]} Array of spottable elements and containers
387
+ * @returns {Node[]} Array of spottable elements and containers
387
388
  * @memberof spotlight/container
388
389
  * @private
389
390
  */
390
- var _getDeepSpottableDescendants = exports.getDeepSpottableDescendants = function getDeepSpottableDescendants(containerId, excludedContainers) {
391
+ var _getDeepSpottableDescendants = exports.getDeepSpottableDescendants = function getDeepSpottableDescendants(containerId, excludedContainers, useLastFocusedElement) {
391
392
  return getSpottableDescendants(containerId).map(function (n) {
392
393
  if (isContainer(n)) {
393
394
  var id = getContainerId(n);
@@ -395,7 +396,7 @@ var _getDeepSpottableDescendants = exports.getDeepSpottableDescendants = functio
395
396
  var hasSpottedControl = getContainerLastFocusedElement(id);
396
397
  if (excludedContainers && excludedContainers.indexOf(id) >= 0) {
397
398
  return [];
398
- } else if (config && !config.enterTo && (!hasSpottedControl || hasSpottedControl && !config.overflow)) {
399
+ } else if (config && !config.enterTo && (useLastFocusedElement || !hasSpottedControl || hasSpottedControl && !config.overflow)) {
399
400
  return _getDeepSpottableDescendants(id, excludedContainers);
400
401
  }
401
402
  }
@@ -859,7 +860,7 @@ function persistLastFocusedElement(containerId) {
859
860
  if (cfg) {
860
861
  var lastFocusedElement = cfg.lastFocusedElement;
861
862
  if (lastFocusedElement) {
862
- var all = _getDeepSpottableDescendants(containerId);
863
+ var all = _getDeepSpottableDescendants(containerId, [], true);
863
864
  var lastFocusedKey = cfg.lastFocusedPersist(lastFocusedElement, all);
864
865
 
865
866
  // store lastFocusedKey and release node reference to lastFocusedElement
@@ -882,7 +883,7 @@ function persistLastFocusedElement(containerId) {
882
883
  function restoreLastFocusedElement(containerId) {
883
884
  var cfg = getContainerConfig(containerId);
884
885
  if (cfg && cfg.lastFocusedKey) {
885
- var all = _getDeepSpottableDescendants(containerId);
886
+ var all = _getDeepSpottableDescendants(containerId, [], true);
886
887
  var lastFocusedElement = cfg.lastFocusedRestore(cfg.lastFocusedKey, all);
887
888
 
888
889
  // restore lastFocusedElement and release lastFocusedKey