Skip to content

Commit a067601

Browse files
refactor(ui5-rating-indicator): allow deselecting rating by clicking the same star (#12180)
1 parent f25d80e commit a067601

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

packages/main/cypress/specs/RatingIndicator.cy.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,5 +275,29 @@ describe("RatingIndicator", () => {
275275

276276
cy.get("@changeEvent").should("have.callCount", 17);
277277
});
278+
279+
it("Second click on same star clears the RatingIndicator value", () => {
280+
cy.mount(
281+
<RatingIndicator></RatingIndicator>
282+
);
283+
284+
cy.get("[ui5-rating-indicator")
285+
.shadow()
286+
.find("li")
287+
.eq(3)
288+
.as("star");
289+
290+
cy.get("@star")
291+
.realClick();
292+
293+
cy.get("[ui5-rating-indicator")
294+
.should("have.attr", "value", 4);
295+
296+
cy.get("@star")
297+
.realClick();
298+
299+
cy.get("[ui5-rating-indicator]")
300+
.should("have.attr", "value", 0);
301+
})
278302
});
279303
});

packages/main/src/RatingIndicator.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,7 @@ class RatingIndicator extends UI5Element {
237237

238238
if (targetValue !== null) {
239239
this.value = parseInt(targetValue);
240-
241-
if (this.value === 1 && this._liveValue === 1) {
240+
if (this.value === this._liveValue) {
242241
this.value = 0;
243242
}
244243

0 commit comments

Comments
 (0)