Allow vote unset by clicking on star

Created on 19 May 2020, about 4 years ago
Updated 14 June 2024, 14 days ago

Currently, to unset a vote, the field must have "Allow users to cancel their ratings." Now that #3136330: Don't set non-zero default value fallback for Stars Widget form β†’ is fixed, admins can set 0 stars as a default value. However, if "Allow users to cancel their ratings" is unchecked then there's no way for them to unset previous selection unless they change that setting, save, go back to the edit form, delete the value, unset the setting and resave -- obviously cumbersome.

Attaching a patch that allows clicking a star to set the rating to 0 if "Allow users to cancel their ratings" is checked OR the user is on the field config form.

With this in, we could add secondary field settings for disallowing/allowing this behavior for frontend users, hiding/showing the X icon, etc.

πŸ“Œ Task
Status

Needs work

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mrweiner

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¨πŸ‡¦Canada liquidcms

    I think this would support what i am trying to build. I want to have one widget/star/whatever that when a user clicks it, it adds 1 to the vote total. And, if they click it again, it removes their vote.

    With latest version of fivestar i get a star and an X. Not ideal but i could make that work with css. But selecting the X (to cancel) does nothing. Adding this patch changes nothing.

    I also am not sure what the option for 0 stars would do or if it is required for the solution discussed here; but i don't have the option of 0 stars when configuring the field.

Production build 0.69.0 2024