-
Notifications
You must be signed in to change notification settings - Fork 218
Fix Attribute terms sometimes being assigned children #8720
base: trunk
Are you sure you want to change the base?
Conversation
Attribute terms (e.g. “Blue”, “Yellow”) have their own `id` property which sometimes can overlap with their Taxonomy `id` (e.g. in the test case, “Blue” had the same `id` as the “Size” taxonomy), and the function building the tree representation for the `SearchListControl` would erroneously assign children to it. To fix this, we do an ugly patch here: we rename the `id` key of `AttributeTerm` when changed to a `SearchListItem` to `termId` instead, so we can differentiate. We do this because other items passed to `SearchListControl` might possibly have several layers of children, but we are sure that in the case of terms, we only have on level deep. This may need a better refactoring at some point.
The release ZIP for this PR is accessible via:
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
assets/js/blocks/attribute-filter/edit.tsx
assets/js/editor-components/search-list-control/search-list-control.tsx |
Size Change: +484 B (0%) Total Size: 1.12 MB
ℹ️ View Unchanged
|
This PR has been marked as If deemed still relevant, the pr can be kept active by ensuring it's up to date with the main branch and removing the stale label. |
This PR has been marked as If deemed still relevant, the pr can be kept active by ensuring it's up to date with the main branch and removing the stale label. |
I'm converting this PR to a draft as there are side effects of this fix that are not resolved yet. |
@kmanijak I'd say we should specify what these side-effects are, so that they can be resolved. |
@kmanijak News on this? |
Hey @sunyatasattva, I agree with that!
I was AFK recently, I'll try to revisit that in the upcoming days as I don't remember the exact details from top of my head 🙌 |
Here's a video showing the problems of choosing the Product Attributes in the Products block: products-8720.mov |
Attribute terms (e.g. “Blue”, “Yellow”) have their own
id
property which sometimes can overlap with their Taxonomyid
(e.g. in the test case, “Blue” had the sameid
as the “Size” taxonomy), and the function building the tree representation for theSearchListControl
would erroneously assign children to it.To fix this, we do an ugly patch here: we rename the
id
key ofAttributeTerm
when changed to aSearchListItem
totermId
instead, so we can differentiate. We do this because other items passed toSearchListControl
might possibly have several layers of children, but we are sure that in the case of terms, we only have on level deep.This may need a better refactoring at some point.
Fixes woocommerce/woocommerce#42438
Testing
User Facing Testing
WooCommerce Visibility