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

@W-18014214 useBlockNavigation implementation in SEO #2288

Open
wants to merge 27 commits into
base: extensibility/seo-feature
Choose a base branch
from

Conversation

jeremy-jung1
Copy link
Collaborator

@jeremy-jung1 jeremy-jung1 commented Feb 24, 2025

W-18014214

Description

This is the implementation of the useBlockNavigation function in pwa-kit-react-sdk and its example usage with a temporary callback that executes a timeout. In W-17530042 this callback will be replaced with logic that calls the getUrlMapping API and updates the routes.

A change is also made in extension-chakra-storefront that adds a loading screen between the header and the footer while the navigation is blocked.

Types of Changes

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Breaking change (could cause existing functionality to not work as expected)
  • Other changes (non-breaking changes that does not fit any of the above)

Changes

  • Added extension-seo-url-mapping and . The name of this extension might still be up for debate
  • Added loading screen to extension-chakra-storefront
  • Implemented useBlockNavigation in pwa-kit-react-sdk

How to Test-Drive This PR

Testing that the navigation is being blocked with a loading screen and that the latest clicked link is activated

  • (step1) Go to https://aaa-jeremy-chicken-soup.mobify-storefront-staging.com/
  • (step2) Click on a link in the header (e.g. Men's -> Accessories -> Ties) and then immediately click on another link in the header (e.g. Women's -> Clothing > Outfits)
  • (step3) See that there is a spinning loader between header and footer, and shortly after the contents of the second link you pressed (e.g. Women's -> Clothing > Outfits) shows up.

Testing that when extension-seo-url-mapping is disabled, the navigation works like it used to

Checklists

General

  • Changes are covered by test cases
  • CHANGELOG.md updated with a short description of changes (not required for documentation updates)

Accessibility Compliance

You must check off all items in one of the follow two lists:

  • There are no changes to UI

or...

Localization

  • Changes include a UI text update in the Retail React App (which requires translation)

@jeremy-jung1 jeremy-jung1 requested a review from a team as a code owner February 24, 2025 23:54
* @param {function} func
* @returns {boolean} State that is set to true during blocking, false otherwise.
*/
export const useBlockNavigation = (func) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Commenting to make it clearer what's been added: this hook will be added to pwa-kit-react-sdk

@jeremy-jung1 jeremy-jung1 changed the title Draft for useBlock in SEO @W-18014214 useBlockNavigation implementation in SEO Mar 25, 2025
@@ -20,13 +20,16 @@
},
"devDependencies": {
"@chakra-ui/react": "^2.8.2",
"@chakra-ui/skip-nav": "^2.0.15",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In spite of deleting node_modules and package-lock.json in this package and extension-chakra-storefront and doing npm install, the error:
Module not found: Error: Can't resolve '@chakra-ui/skip-nav' in '/Users/jangho.jung/Documents/pwa-kit/packages/extension-chakra-storefront/src/components/with-layout'

kept showing up. Adding the package in here temporarily fixed it. Will need to see what's causing this issue

} from '@salesforce/pwa-kit-extension-sdk/react'
type SeoHOCProps = React.ComponentPropsWithoutRef<any>

const seoHOC = <P extends object>(WrappedComponent: React.ComponentType<P>) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Commenting to make it clear what's been added:

an seo HOC that has the callback function that will soon hold the getUrlMapping API call. Currently it is a timeout.

*/
export type Config = Required<UserConfig>

interface StoreSlice {
Copy link
Collaborator Author

@jeremy-jung1 jeremy-jung1 Mar 26, 2025

Choose a reason for hiding this comment

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

Commenting to make it clear what's been added:

An extension store for isBlocked and its state updater so that it can be accessed from the storefront extension

Lint and add ignore file
@bendvc bendvc added the skip changelog Skip the "Changelog Check" GitHub Actions step even if the Changelog.md files are not updated label Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip changelog Skip the "Changelog Check" GitHub Actions step even if the Changelog.md files are not updated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants