Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui5-rating-indicator): correct half icon appearance #10263

Merged
merged 2 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
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
39 changes: 39 additions & 0 deletions packages/main/cypress/specs/RatingIndicator.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { html } from "lit";
import "../../src/RatingIndicator.js";

describe("RatingIndicator", () => {
describe("Half Icon appearance", () => {
it("Half icon should be filled when rating indicator is disabled", () => {
const attributeValue = "favorite";

cy.mount(html`<ui5-rating-indicator value="2.5" disabled></ui5-rating-indicator>`);

cy.get("[ui5-rating-indicator]")
.shadow()
.find(".ui5-rating-indicator-item-half [ui5-icon]")
.should("have.attr", "name", attributeValue);
});

it("Half icon should be filled when rating indicator is readonly", () => {
const attributeValue = "favorite";

cy.mount(html`<ui5-rating-indicator value="2.5" readonly></ui5-rating-indicator>`);

cy.get("[ui5-rating-indicator]")
.shadow()
.find(".ui5-rating-indicator-item-half [ui5-icon]")
.should("have.attr", "name", attributeValue);
});

it("Half icon should be border only when rating indicator is regular", () => {
const attributeValue = "unfavorite";

cy.mount(html`<ui5-rating-indicator value="2.5"></ui5-rating-indicator>`);

cy.get("[ui5-rating-indicator]")
.shadow()
.find(".ui5-rating-indicator-item-half [ui5-icon]")
.should("have.attr", "name", attributeValue);
});
});
});
2 changes: 1 addition & 1 deletion packages/main/src/RatingIndicator.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</li>
{{else if this.halfStar}}
<li class="ui5-rating-indicator-item ui5-rating-indicator-item-half">
<ui5-icon data-ui5-value="{{this.index}}" name="unfavorite"></ui5-icon>
<ui5-icon data-ui5-value="{{this.index}}" name="{{../halfStarIconName}}"></ui5-icon>
<div class="ui5-rating-indicator-half-icon-wrapper">
<ui5-icon data-ui5-value="{{this.index}}" name="favorite" class="ui5-rating-indicator-half-icon"></ui5-icon>
</div>
Expand Down
4 changes: 4 additions & 0 deletions packages/main/src/RatingIndicator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ class RatingIndicator extends UI5Element {
this._focused = false;
}

get halfStarIconName() {
return this.disabled || this.readonly ? "favorite" : "unfavorite";
}

get effectiveTabIndex() {
const tabindex = this.getAttribute("tabindex");
return this.disabled ? "-1" : tabindex || "0";
Expand Down