cycle through tabs/menu items

This commit is contained in:
Cory LaViska
2022-03-24 08:50:44 -04:00
parent 4b22fd2095
commit 756b86a416
3 changed files with 14 additions and 5 deletions

View File

@@ -13,7 +13,8 @@ _During the beta period, these restrictions may be relaxed in the event of a mis
- Fixed a bug that prevented `setCustomValidity()` from working with `<sl-radio-button>`
- Fixed a bug where the right border of a checked `<sl-radio-button>` was the wrong color
- Fixed a bug that prevented a number of properties, methods, etc. from being documented in `<sl-radio>` and `<sl-radio-button>`
- Once again removed path aliasing because it doesn't work with Web Test Runner's esbuild plugin
- Updated `<sl-tab-group>` and `<sl-menu>` to cycle through tabs and menu items instead of stopping at the first/last when using the keyboard
- Removed path aliasing (again) because it doesn't work with Web Test Runner's esbuild plugin
## 2.0.0-beta.72

View File

@@ -162,10 +162,10 @@ export default class SlMenu extends LitElement {
}
if (index < 0) {
index = 0;
index = items.length - 1;
}
if (index > items.length - 1) {
index = items.length - 1;
index = 0;
}
this.setCurrentItem(items[index]);

View File

@@ -187,12 +187,20 @@ export default class SlTabGroup extends LitElement {
(['top', 'bottom'].includes(this.placement) && event.key === 'ArrowLeft') ||
(['start', 'end'].includes(this.placement) && event.key === 'ArrowUp')
) {
index = Math.max(0, index - 1);
index--;
} else if (
(['top', 'bottom'].includes(this.placement) && event.key === 'ArrowRight') ||
(['start', 'end'].includes(this.placement) && event.key === 'ArrowDown')
) {
index = Math.min(this.tabs.length - 1, index + 1);
index++;
}
if (index < 0) {
index = this.tabs.length - 1;
}
if (index > this.tabs.length - 1) {
index = 0;
}
this.tabs[index].focus({ preventScroll: true });