@vaadin/a11y-base 25.2.0-alpha11 → 25.2.0-alpha13

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": "25.2.0-alpha11",
3
+ "version": "25.2.0-alpha13",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -32,15 +32,15 @@
32
32
  ],
33
33
  "dependencies": {
34
34
  "@open-wc/dedupe-mixin": "^1.3.0",
35
- "@vaadin/component-base": "25.2.0-alpha11",
35
+ "@vaadin/component-base": "25.2.0-alpha13",
36
36
  "lit": "^3.0.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@vaadin/chai-plugins": "25.2.0-alpha11",
40
- "@vaadin/test-runner-commands": "25.2.0-alpha11",
39
+ "@vaadin/chai-plugins": "25.2.0-alpha13",
40
+ "@vaadin/test-runner-commands": "25.2.0-alpha13",
41
41
  "@vaadin/testing-helpers": "^2.0.0",
42
42
  "sinon": "^21.0.2"
43
43
  },
44
44
  "customElements": "custom-elements.json",
45
- "gitHead": "fdc37e932709f95491a027aeb2090911cb7528c6"
45
+ "gitHead": "a1052aee053529ffcef1a1e9be2c855ed3e98cb2"
46
46
  }
@@ -124,7 +124,7 @@ export const KeyboardDirectionMixin = (superclass) =>
124
124
 
125
125
  if (idx >= 0) {
126
126
  event.preventDefault();
127
- this._focus(idx, { focusVisible: true }, true);
127
+ this._focus(idx, { focusVisible: true, preventScroll: true }, true);
128
128
  }
129
129
  }
130
130
 
package/src/list-mixin.js CHANGED
@@ -282,40 +282,19 @@ export const ListMixin = (superClass) =>
282
282
  });
283
283
  this._setFocusable(idx);
284
284
  this._scrollToItem(idx);
285
- super._focus(idx, options);
285
+ super._focus(idx, options ?? { preventScroll: true });
286
286
  }
287
287
 
288
288
  /**
289
- * Scroll the container to have the next item by the edge of the viewport.
289
+ * Scroll the container to have the item visible.
290
290
  * @param {number} idx
291
291
  * @protected
292
292
  */
293
293
  _scrollToItem(idx) {
294
- const item = this.items[idx];
295
- if (!item) {
296
- return;
294
+ const item = this._getItems()[idx];
295
+ if (item) {
296
+ item.scrollIntoView({ block: 'nearest', inline: 'nearest' });
297
297
  }
298
-
299
- const props = this._vertical ? ['top', 'bottom'] : this._isRTL ? ['right', 'left'] : ['left', 'right'];
300
-
301
- const scrollerRect = this._scrollerElement.getBoundingClientRect();
302
- const nextItemRect = (this.items[idx + 1] || item).getBoundingClientRect();
303
- const prevItemRect = (this.items[idx - 1] || item).getBoundingClientRect();
304
-
305
- let scrollDistance = 0;
306
- if (
307
- (!this._isRTL && nextItemRect[props[1]] >= scrollerRect[props[1]]) ||
308
- (this._isRTL && nextItemRect[props[1]] <= scrollerRect[props[1]])
309
- ) {
310
- scrollDistance = nextItemRect[props[1]] - scrollerRect[props[1]];
311
- } else if (
312
- (!this._isRTL && prevItemRect[props[0]] <= scrollerRect[props[0]]) ||
313
- (this._isRTL && prevItemRect[props[0]] >= scrollerRect[props[0]])
314
- ) {
315
- scrollDistance = prevItemRect[props[0]] - scrollerRect[props[0]];
316
- }
317
-
318
- this._scroll(scrollDistance);
319
298
  }
320
299
 
321
300
  /**