Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,8 @@ export class Carousel
return;
}

const lastItem = this.items.length - 1;

switch (event.key) {
case " ":
case "Enter":
Expand All @@ -512,13 +514,19 @@ export class Carousel
break;
case "Home":
event.preventDefault();
if (this.selectedIndex === 0) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this move before event.preventDefault so event isn't prevented if nothing happens?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd still expect it to be prevented. Without it, the Home / End keys could navigate the Carousel with one keystroke and then unexpectedly scroll the page with the next.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. makes sense.

return;
}
this.direction = "backward";
this.setSelectedItem(0, true);
break;
case "End":
event.preventDefault();
if (this.selectedIndex === lastItem) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this move before event.preventDefault so event isn't prevented if nothing happens?

return;
}
this.direction = "forward";
this.setSelectedItem(this.items.length - 1, true);
this.setSelectedItem(lastItem, true);
break;
}
};
Expand Down