Skip to content

Commit

Permalink
update to feedback selection
Browse files Browse the repository at this point in the history
clicking the feedback text was throwing console log, so, updated logic to consider the feedback text for selection
  • Loading branch information
GouthamShiv authored Feb 2, 2022
1 parent f682234 commit 6ca6079
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions feedback-ui-design/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ const panel = document.querySelector('#panel')
let selectedRating = 'Satisfied'

ratingsContainer.addEventListener('click', (e) => {
if(e.target.parentNode.classList.contains('rating')) {
if(e.target.parentNode.classList.contains('rating') && e.target.nextElementSibling) {
removeActive()
e.target.parentNode.classList.add('active')
selectedRating = e.target.nextElementSibling.innerHTML
}
if(e.target.classList.contains('rating')) {
} else if(
e.target.parentNode.classList.contains('rating') &&
e.target.previousSibling &&
e.target.previousElementSibling.nodeName === 'IMG'
) {
removeActive()
e.target.classList.add('active')
selectedRating = e.target.nextElementSibling.innerHTML
e.target.parentNode.classList.add('active')
selectedRating = e.target.innerHTML
}

})
Expand All @@ -32,4 +35,4 @@ function removeActive() {
for(let i = 0; i < ratings.length; i++) {
ratings[i].classList.remove('active')
}
}
}

0 comments on commit 6ca6079

Please sign in to comment.