If a comment is entered with a rating, any user can view that comment once it's published and the stars give the impression that they can be changed since their styling indicates it and if the user clicks on a different star the rating appears to stick to that newly selected star for the duration of the current page load.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

swickham created an issue. See original summary.

swickham’s picture

Status: Active » Needs review
FileSize
919 bytes

I didn't spend much time to make sure this was the best way to go about it, but here's a patch that checks to see if the element being created has a value already selected, only the ones with no value selected create stars with the tag that seems to be causing the confusion.

cbildstein’s picture

Tried out the #2 patch but ran into issues in cases where you set a default rating value and the widget would never work in the form because of this check:

if ($select.val() === '-') {

I updated it to check for the form value instead, so the widget would only display when within an actual form where you would need the widget.

if (element.form) {

Seemed to work in my use cases but should be further tested.

Mitriy-Bug’s picture

FileSize
74.57 KB

But then all the stars are grey and not clear what the rating

Mitriy-Bug’s picture

FileSize
1022 bytes

Made, check. You only need the styles to correct

<style>
div.fivestar-widget .star span {
  display: block;
  width: 100%;
  height: 100%;
  background-position: 0 0; /* RTL */
  cursor: pointer;
}
div.fivestar-widget div.on span {
  background-position: 0 -16px; /* RTL */
}
.fivestar-oxygen div.fivestar-widget .star span {
  background-image: url(star.png);
}
</style>
sorabh.v6’s picture

Status: Needs review » Needs work

None of the patches are working for me. I am using dev-1.x and "reference": "ee888670ec12". I created the rating from the admin account and I am able to change the rating stars as an anonymous user. Though they get reset when I refresh the page.

sorabh.v6’s picture

Status: Needs work » Reviewed & tested by the community

Its working, forgot to clear browser cache and browser was using cached js. It's working for me.

StefanRoman’s picture

This code worked for me div.fivestar-widget div.on { background-position: 0 -16px; /* RTL */ }, instead of div.fivestar-widget div.on span { background-position: 0 -16px; /* RTL */ }. Thanks for it.

dbjpanda’s picture

Getting error corrupt patch at line 21 after apply https://www.drupal.org/project/fivestar/issues/2920834

init90’s picture

Status: Reviewed & tested by the community » Fixed

Looks like the problem already fixed in current dev release. Thanks, everyone!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.