Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace support review component with shared one. #408

Closed

Conversation

StevenDufresne
Copy link
Contributor

This PR updates the support forum reviews stars & bars to use the shared component.

Related: WordPress/wporg-mu-plugins#633, #380

Important

The forums display more precise rating numbers, while the new components round ratings to the nearest 0.5. Since we already use the new components in multiple places, if we want to keep the current precision, we should do it everywhere at once in the new components.

Considerations

The ratings-stars and ratings-bars components expect the context to contain postId. However, based on how bbPress works and how it's been modified, the postId is not set.

As a result, I've made use of the render_block_context block to set it. we still don't use that in wporg_set_rating_data, as we need to call wporg_support_get_compat_object to get all the relevant data. It feels a bit silly, but feels better than the alternative. The alternative would be to change the blocks to not return if the post_id is not set. That feels less predictable.

I've also done some minor styling updates.

Screenshots

Before After
Screenshot 2024-10-25 at 12 08 11 PM Screenshot 2024-10-25 at 11 52 50 AM
Screenshot 2024-10-25 at 11 49 34 AM Screenshot 2024-10-25 at 11 53 09 AM

@StevenDufresne StevenDufresne requested a review from ryelle October 28, 2024 03:18
@ryelle
Copy link
Contributor

ryelle commented Oct 30, 2024

The forums display more precise rating numbers, while the new components round ratings to the nearest 0.5. Since we already use the new components in multiple places, if we want to keep the current precision, we should do it everywhere at once in the new components.

I remembered this discussion — it was already like this in the old theme, so this is just fixing that inconsistency. I have no strong preference on which precision is better, but if we want to change it, we can just transfer that linked issue to wporg-mu-plugins and update the wporg/ratings-stars block.

As a result, I've made use of the render_block_context block to set it. we still don't use that in wporg_set_rating_data, as we need to call wporg_support_get_compat_object to get all the relevant data. It feels a bit silly, but feels better than the alternative. The alternative would be to change the blocks to not return if the post_id is not set. That feels less predictable.

Technically post_id is used in the filter, so it could be used, though it isn't used here. You could just return something truthy from wporg_render_block_context if there's any concern about the performance of calling wporg_support_get_compat_object twice.

Copy link
Contributor

@ryelle ryelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a few little notes.

@StevenDufresne StevenDufresne requested a review from ryelle October 31, 2024 05:40
Copy link
Contributor

@ryelle ryelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! One more minor comment about return types, feel free to grab either code suggestion 🙂

bazza pushed a commit that referenced this pull request Nov 13, 2024
bazza pushed a commit that referenced this pull request Nov 13, 2024
StevenDufresne added a commit to StevenDufresne/wordpress.org that referenced this pull request Nov 14, 2024
StevenDufresne added a commit to StevenDufresne/wordpress.org that referenced this pull request Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants