-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Show categories' parents in product view #4846
Conversation
🦋 Changeset detectedLatest commit: 00770f8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
src/products/components/ProductOrganization/ProductOrganization.test.tsx
Outdated
Show resolved
Hide resolved
src/searches/useCategorySearch.ts
Outdated
@@ -14,6 +14,14 @@ export const searchCategories = gql` | |||
node { | |||
id | |||
name | |||
ancestors(first: $first) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you pass here the same variable as for the root query (categories), which is wrong, this number should be either configured separately or even hardcoded so now the number of loaded categories indicates also amount of ancestors, which is not really expected here: having eg first 2 categories I still want eg. to have 3 ancestors (not 2)
Consider:
- keep number of ancestors as separate variable
- search categories query is used in several places, do you need ancestors in each? perhaps a separated query is more reasonable here? (think about it if you have time)
@mirekm We've decided to reverse the order to "Grandparent / parent / category" |
0241511
to
ebd3a1c
Compare
let availableCategories = categories; | ||
|
||
if (selectedProductCategory) { | ||
availableCategories = [...categories, selectedProductCategory]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: I think we should avoid using let
if it can be solved with a ternary operator
let availableCategories = categories; | |
if (selectedProductCategory) { | |
availableCategories = [...categories, selectedProductCategory]; | |
} | |
const availableCategories = selectedProductCategory ? [...categories, selectedProductCategory] : categories; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right, thanks 😸
* show categories' ancestors * add tests * cleanup * changeset * cr fixes * show parents when category is selected * show only parent and grandparent category * reverse order * properly align input with adornment * fix test * improve categories display * fix * fix * fix display while loading * improve ancestor categories display * fix tests * show ancestors of saved category on first load * gql cleanup * fix tests * update macaw * cr fix
What type of PR is this?
Related Issues or Documents
Usage Instructions, Screenshots, Recordings
Selected category with ancestors:
Have you written tests?
[Optional] Description