Skip to content

Commit

Permalink
🐛 Deleting first activated color will properly activate the second one
Browse files Browse the repository at this point in the history
  • Loading branch information
keelus committed Jul 30, 2023
1 parent 41171fa commit be39ceb
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions web/static/js/panels/LedControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,15 @@ $(".color .delete").on("click", (e) => {
},
success: function (r) {
let colorParent = $(e.target).closest(".color")


if ($(colorParent).hasClass("selected")) { // If deleted is the activated
$(".color.selected").removeClass("selected")
$(colorParent).remove()
$($(`[mode='${mode}'] .color`)[0]).addClass("selected")
} else {
$(colorParent).remove()
}

$(colorParent).remove()


showPopup(`Color removed.`, 3000, "success")
Expand All @@ -130,14 +132,16 @@ $(".gradient .delete").on("click", (e) => {
},
success: function (r) {
let gradientParent = $(e.target).closest(".gradient")


if ($(gradientParent).hasClass("selected")) { // If deleted is the activated
$(".gradient.selected").removeClass("selected")
$(gradientParent).remove()
$($(".gradient")[0]).addClass("selected")
} else {
$(gradientParent).remove()
}

$(gradientParent).remove()

showPopup(`Gradient deleted.`, 3000, "success")
},
error: function(r) {
Expand Down

0 comments on commit be39ceb

Please sign in to comment.