Skip to content

Conversation

@mirianrmrizzi
Copy link

@mirianrmrizzi mirianrmrizzi commented Oct 14, 2025

What problem is this solving?

On mobile, navigating between certain categories sometimes caused a 404 error. The issue happens because the URL concatenates the previous category and subcategory paths with the new category.

Example:
Navigate first to Banheiros > Duchas e Chuveiros.
Then go to Climatizador.
The URL incorrectly becomes: https://www.obramax.com.br/banheiros/duchas-e-chuveiros/climatizacao-e-ventilacao/climatizadores-de-ar instead of the correct path. This results in a 404 page.

WS: https://ombrec1585--lojaobramax.myvtex.com/

How should this be manually tested?

  1. Open the website on a mobile device or use a mobile viewport in the browser.
  2. Navigate to one category, then select another category in the menu.
  3. Verify that the URL updates correctly and the new category page loads without a 404 error.

Screenshots or example usage:

Before: https://jam.dev/c/27bb0666-a0ac-44ef-89b6-78e99ba15bac
After: https://www.awesomescreenshot.com/video/45282811?key=71f19bd0438e1949659b9a920819b6e9

@vtex-io-ci-cd
Copy link

vtex-io-ci-cd bot commented Oct 14, 2025

Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖

Please select which version do you want to release:

  • Patch (backwards-compatible bug fixes)

  • Minor (backwards-compatible functionality)

  • Major (incompatible API changes)

And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.

  • No thanks, I would rather do it manually 😞

@vtex-io-docs-bot
Copy link

vtex-io-docs-bot bot commented Oct 14, 2025

Beep boop 🤖

I noticed you didn't make any changes at the docs/ folder

  • There's nothing new to document 🤔
  • I'll do it later 😞

In order to keep track, I'll create an issue if you decide now is not a good time

  • I just updated 🎉🎉

@mirianrmrizzi
Copy link
Author

Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖

Please select which version do you want to release:

  • Patch (backwards-compatible bug fixes)
  • Minor (backwards-compatible functionality)
  • Major (incompatible API changes)

And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.

  • No thanks, I would rather do it manually 😞

@mirianrmrizzi
Copy link
Author

Beep boop 🤖

I noticed you didn't make any changes at the docs/ folder

  • There's nothing new to document 🤔
  • I'll do it later 😞

In order to keep track, I'll create an issue if you decide now is not a good time

  • I just updated 🎉🎉

No new documentation is required for this fix since it only resolves a 404 error on mobile category navigation. No new functionality or configuration was added.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a 404 error that occurred on mobile when navigating between categories in the mega menu. The bug was caused by relative URL path concatenation, where clicking on a new category would append its slug to the previous category's path instead of replacing it.

Changes:

  • Fixed URL navigation by adding a leading slash to category slugs when assigning to window.location.href
  • Refactored code formatting for improved readability (arrow function syntax, indentation consistency)
  • Updated CHANGELOG.md to document the fix

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
react/MegaMenu/components/Submenu.tsx Fixed category navigation by changing window.location.assign(category.slug) to window.location.href = '/${category.slug}' to prevent URL concatenation; also includes code formatting improvements
CHANGELOG.md Added entry documenting the 404 error fix in the Unreleased section

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@vsseixaso vsseixaso left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

2 participants