Skip to content

Commit

Permalink
fix(ui5-carousel): correct navigation buttons behavior (#5302)
Browse files Browse the repository at this point in the history
The ui5-carousel's navigation buttons now will focus the carousel after
being clicked. This avoids losing the focus when the first/last button
of the carousel dissapears when reaching the fist/last pages.

Fixes: #5125
  • Loading branch information
gmkv committed Jun 2, 2022
1 parent 0dcdbbe commit 34027cd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/main/src/Carousel.hbs
Expand Up @@ -70,7 +70,7 @@
class="ui5-carousel-navigation-button {{classes.navPrevButton}}"
icon="slim-arrow-left"
tabindex="-1"
@click={{navigateLeft}}
@click={{_navButtonClick}}
></ui5-button>
{{/inline}}

Expand All @@ -81,6 +81,6 @@
class="ui5-carousel-navigation-button {{classes.navNextButton}}"
icon="slim-arrow-right"
tabindex="-1"
@click={{navigateRight}}
@click={{_navButtonClick}}
></ui5-button>
{{/inline}}
10 changes: 10 additions & 0 deletions packages/main/src/Carousel.js
Expand Up @@ -479,6 +479,16 @@ class Carousel extends UI5Element {
}
}

_navButtonClick(event) {
if (event.target.hasAttribute("arrow-forward")) {
this.navigateRight();
} else {
this.navigateLeft();
}

this.focus();
}

/**
* Changes the currently displayed page.
* @param {Integer} itemIndex The index of the target page
Expand Down
2 changes: 2 additions & 0 deletions packages/main/src/themes/Carousel.css
Expand Up @@ -106,6 +106,8 @@
box-shadow: none;
cursor: pointer;
outline-offset: .1rem;

--_ui5_button_focused_border_radius: 50%;
}

.ui5-carousel-navigation-arrows .ui5-carousel-navigation-button {
Expand Down

0 comments on commit 34027cd

Please sign in to comment.