Compare commits

..

4 Commits

Author SHA1 Message Date
Cory LaViska
886049d714 update PR link 2023-07-05 16:45:14 -04:00
Cory LaViska
848c059d51 don't steal focus when removing focused tree items; #1428 2023-07-05 16:44:02 -04:00
Cory LaViska
8ffbd02db7 update changelog 2023-07-05 16:32:59 -04:00
Evan Harrison
e88d57d17d change .floor to .ceil in getCurrentPage; modify prev function to return to closest previous snappable index (#1420) 2023-07-05 16:26:00 -04:00
4 changed files with 19 additions and 11 deletions

View File

@@ -15,9 +15,10 @@ New versions of Shoelace are released as-needed and generally occur when a criti
## Next
- Added tests for `<sl-qr-code>` [#1416]
- Added support for pressing [[Space]] to select/toggle selected `<sl-menu-item>` elements [#1429]
- Fixed a bug in `<sl-qr-code>` where the `background` attribute was never passed to the QR code [#1416]
- Fixed a bug in `<sl-dropdown>` where aria attributes were incorrectly applied to the default `<slot>` causing Lighthouse errors [#1417]
- Fixed a bug in `<sl-carousel>` that caused navigation to work incorrectly in some case [#1420]
- Fixed a bug in `<sl-tree>` that caused focus to be stolen when removing focused tree items [#1430]
## 2.5.2

View File

@@ -141,7 +141,7 @@ export default class SlCarousel extends ShoelaceElement {
}
private getCurrentPage() {
return Math.floor(this.activeSlide / this.slidesPerPage);
return Math.ceil(this.activeSlide / this.slidesPerPage);
}
private getSlides({ excludeClones = true }: { excludeClones?: boolean } = {}) {
@@ -325,7 +325,15 @@ export default class SlCarousel extends ShoelaceElement {
* @param behavior - The behavior used for scrolling.
*/
previous(behavior: ScrollBehavior = 'smooth') {
this.goToSlide(this.activeSlide - this.slidesPerMove, behavior);
let previousIndex = this.activeSlide || this.activeSlide - this.slidesPerMove;
let canSnap = false;
while (!canSnap && previousIndex > 0) {
previousIndex -= 1;
canSnap = Math.abs(previousIndex - this.slidesPerMove) % this.slidesPerMove === 0;
}
this.goToSlide(previousIndex, behavior);
}
/**

View File

@@ -45,8 +45,8 @@ export default class SlMenu extends ShoelaceElement {
}
private handleKeyDown(event: KeyboardEvent) {
// Make a selection when pressing enter or space
if (event.key === 'Enter' || event.key === ' ') {
// Make a selection when pressing enter
if (event.key === 'Enter') {
const item = this.getCurrentItem();
event.preventDefault();
@@ -54,6 +54,11 @@ export default class SlMenu extends ShoelaceElement {
item?.click();
}
// Prevent scrolling when space is pressed
if (event.key === ' ') {
event.preventDefault();
}
// Move the selection when pressing down or up
if (['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(event.key)) {
const items = this.getAllItems();

View File

@@ -159,14 +159,8 @@ export default class SlTree extends ShoelaceElement {
private handleTreeChanged = (mutations: MutationRecord[]) => {
for (const mutation of mutations) {
const addedNodes: SlTreeItem[] = [...mutation.addedNodes].filter(SlTreeItem.isTreeItem) as SlTreeItem[];
const removedNodes = [...mutation.removedNodes].filter(SlTreeItem.isTreeItem) as SlTreeItem[];
addedNodes.forEach(this.initTreeItem);
// If the focused item has been removed form the DOM, move the focus to the first focusable item
if (removedNodes.includes(this.lastFocusedItem)) {
this.focusItem(this.getFocusableItems()[0]);
}
}
};