Skip to content

Conversation

@sethidden
Copy link
Contributor

@sethidden sethidden commented Mar 9, 2022

Description

Add the ability to enter subcategories from the side menu on mobile
Before this PR you could only access top level categories like Men, Women, Gear, but now you can enter eg. Men>Tops>Jackets

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Screen.Recording.2022-03-10.at.12.55.52.mov

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@sethidden
Copy link
Contributor Author

sethidden commented Mar 10, 2022

@sethidden sethidden marked this pull request as ready for review March 10, 2022 09:08
@sethidden
Copy link
Contributor Author

sethidden commented Mar 10, 2022

  • Move MobileMenuSidebar to the catalog/category module and change its name so its not misleading
  • Remove useSidebar category functions and put it in separate file that's close to MobileCATEGORYMenuSidebar
  • Maybe break down useSidebar and move to dumb helpers module

@sethidden sethidden force-pushed the bugfix/M2-220-categories-in-mobile-menu branch from 325114a to 86367f4 Compare March 10, 2022 11:49
@@ -0,0 +1,129 @@
<template>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Loads of diffs because I just moved the file, but there were plenty of changes to the template and script

router.push(path);
};
const activeCategory: CategoryTreeInterface = findDeep(categoryTree.value, (value, key) => key === 'slug' && value === route.value.fullPath.replace('/default/c', ''))?.parent;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note the ugly hack with the /default/c replace, but that's the closest I could find to a "unique id" to detect the current category.

@sethidden sethidden force-pushed the bugfix/M2-220-categories-in-mobile-menu branch 2 times, most recently from ee65681 to 7296abf Compare March 10, 2022 12:08
@sethidden sethidden changed the title Bugfix/m2 220 categories in mobile menu feat(theme): support navigating to nested categories in mobile side menu Mar 10, 2022
@sethidden
Copy link
Contributor Author

sethidden commented Mar 10, 2022

  • Hmm the Jira description says The MobileMenuSidebar component is lazy-loaded, not sure if that's done

@sethidden
Copy link
Contributor Author

sethidden commented Mar 10, 2022

  • The useCategory and categoryGetters are removed from MobileMenuSidebar componet this is also not done yet

@sethidden sethidden marked this pull request as draft March 10, 2022 12:29
@sethidden sethidden force-pushed the bugfix/M2-220-categories-in-mobile-menu branch 2 times, most recently from a3d1e41 to 9dbab82 Compare March 10, 2022 14:28
import { CategoryTreeInterface } from '~/modules/catalog/category/types';

export const useMobileCategoryTree = (initialHistory: CategoryTreeInterface[] = []) => {
const history = ref<CategoryTreeInterface[]>(initialHistory);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's something really wrong with TypeScript here as it can't understand the <T = CategoryTreeInterface> syntax, so there's lots of duplication of types

@sethidden sethidden marked this pull request as ready for review March 14, 2022 08:58
@sethidden
Copy link
Contributor Author

need to resolve conflicts, sec

const activeCategoryAncestors = ref(null);
const isLoading = ref(true);
onMounted(async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shouldn't this be useAsync?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably out of scope for this PR, but still

Copy link
Contributor

Choose a reason for hiding this comment

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

The onMounted is good here, because we won't cache the category tree in Redis/cdn so they are loaded on the client-side.

Before this commit there were 2 issues:
- Types from Cypress and Jest fighting for the `expect()` keyword in .spec.ts files
  but this happened only when running tests with Jest (ts-jest)

- TypeScript didn't know where to find the @types/jest (when using
  tsserver), so I changed the typeRoots to point to the parent pkg

This is only a half-solution as I think if I used some composite configs
it'd be more manageable

fix(theme): squash this

fix(theme): squash this
@sethidden sethidden force-pushed the bugfix/M2-220-categories-in-mobile-menu branch from 02cd541 to 9143eea Compare March 14, 2022 11:33
refactor(theme): refactor find active category function to return whole object

squash this

feat(theme): pinia working wip

feat(theme): reorganize folders for helpers

feat(theme): reduce duplication in graphql query

feat(theme): adjust desktop and mobile categories

fix(theme): fix invalid import paths
@sethidden sethidden force-pushed the bugfix/M2-220-categories-in-mobile-menu branch from 9143eea to 060fe77 Compare March 14, 2022 11:39
const activeCategoryAncestors = ref(null);
const isLoading = ref(true);
onMounted(async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

The onMounted is good here, because we won't cache the category tree in Redis/cdn so they are loaded on the client-side.

@Frodigo Frodigo merged commit 1b11e9c into develop Mar 15, 2022
@Frodigo Frodigo deleted the bugfix/M2-220-categories-in-mobile-menu branch March 15, 2022 08:39
@Frodigo Frodigo added this to the 1.0.0-rc.7 milestone Mar 15, 2022
Frodigo pushed a commit that referenced this pull request May 4, 2022
…enu (#709)

* fix(theme): allow spec.ts files to be used

Before this commit there were 2 issues:
- Types from Cypress and Jest fighting for the `expect()` keyword in .spec.ts files
  but this happened only when running tests with Jest (ts-jest)

- TypeScript didn't know where to find the @types/jest (when using
  tsserver), so I changed the typeRoots to point to the parent pkg

This is only a half-solution as I think if I used some composite configs
it'd be more manageable

fix(theme): squash this

fix(theme): squash this

* feat(theme): add nested categories in mobile category menu

refactor(theme): refactor find active category function to return whole object

squash this

feat(theme): pinia working wip

feat(theme): reorganize folders for helpers

feat(theme): reduce duplication in graphql query

feat(theme): adjust desktop and mobile categories

fix(theme): fix invalid import paths
Frodigo pushed a commit that referenced this pull request May 4, 2022
…enu (#709)

* fix(theme): allow spec.ts files to be used

Before this commit there were 2 issues:
- Types from Cypress and Jest fighting for the `expect()` keyword in .spec.ts files
  but this happened only when running tests with Jest (ts-jest)

- TypeScript didn't know where to find the @types/jest (when using
  tsserver), so I changed the typeRoots to point to the parent pkg

This is only a half-solution as I think if I used some composite configs
it'd be more manageable

fix(theme): squash this

fix(theme): squash this

* feat(theme): add nested categories in mobile category menu

refactor(theme): refactor find active category function to return whole object

squash this

feat(theme): pinia working wip

feat(theme): reorganize folders for helpers

feat(theme): reduce duplication in graphql query

feat(theme): adjust desktop and mobile categories

fix(theme): fix invalid import paths
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.

4 participants