Update support forum ratings component #406
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
andratings-bars
components expect the context to containpostId
. However, based on how bbPress works and how it's been modified, thepostId
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 inwporg_set_rating_data
, as we need to callwporg_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