@vaadin/a11y-base 24.3.18 → 24.3.19

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/a11y-base",
3
- "version": "24.3.18",
3
+ "version": "24.3.19",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -32,7 +32,7 @@
32
32
  "dependencies": {
33
33
  "@open-wc/dedupe-mixin": "^1.3.0",
34
34
  "@polymer/polymer": "^3.0.0",
35
- "@vaadin/component-base": "~24.3.18",
35
+ "@vaadin/component-base": "~24.3.19",
36
36
  "lit": "^3.0.0"
37
37
  },
38
38
  "devDependencies": {
@@ -40,5 +40,5 @@
40
40
  "@vaadin/testing-helpers": "^0.6.0",
41
41
  "sinon": "^13.0.2"
42
42
  },
43
- "gitHead": "48c098f213c652b55cf43552226f1aa3fe521189"
43
+ "gitHead": "5e9460d995aabed74fe1d92b17f45fe79c5d9f83"
44
44
  }
@@ -23,20 +23,22 @@ export class FocusRestorationController {
23
23
  /**
24
24
  * Restores focus to the target node that was saved previously with `saveFocus()`.
25
25
  */
26
- restoreFocus() {
26
+ restoreFocus(options) {
27
27
  const focusNode = this.focusNode;
28
28
  if (!focusNode) {
29
29
  return;
30
30
  }
31
31
 
32
+ const preventScroll = options ? options.preventScroll : false;
33
+
32
34
  if (getDeepActiveElement() === document.body) {
33
35
  // In Firefox and Safari, focusing the node synchronously
34
36
  // doesn't work as expected when the overlay is closing on outside click.
35
37
  // These browsers force focus to move to the body element and retain it
36
38
  // there until the next event loop iteration.
37
- setTimeout(() => focusNode.focus());
39
+ setTimeout(() => focusNode.focus({ preventScroll }));
38
40
  } else {
39
- focusNode.focus();
41
+ focusNode.focus({ preventScroll });
40
42
  }
41
43
 
42
44
  this.focusNode = null;
package/src/list-mixin.js CHANGED
@@ -166,7 +166,8 @@ export const ListMixin = (superClass) =>
166
166
  }
167
167
  });
168
168
 
169
- this._setFocusable(selected || 0);
169
+ // When selected is set to -1, focus the first available item.
170
+ this._setFocusable(selected < 0 || !selected ? 0 : selected);
170
171
 
171
172
  const itemToSelect = items[selected];
172
173
  items.forEach((item) => {