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

fix(side nav): Pass ref to SideNavBase and write a test #1130

Merged
merged 1 commit into from
Sep 12, 2024

Conversation

aaryanporwal
Copy link
Contributor

@aaryanporwal aaryanporwal commented Sep 10, 2024

Done

  • Passed the ref to SideNavigationBase component. This fixes the "Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?" error while trying to access ref from SideNavigationLink component."
  • Added a test to check if we're able to properly get value from ref.

QA

Storybook

To see rendered examples of all react-components, run:

yarn start

QA in your project

from react-components run:

yarn build
npm pack

Install the resulting tarball in your project with:

yarn add <path-to-tarball>

QA steps

  • Steps for QA.

Percy steps

  • List any expected visual change in Percy, or write something like "No visual changes expected" if none is expected.

Fixes

Fixes: WD-14589

@webteam-app
Copy link

@aaryanporwal aaryanporwal changed the title fix(side nav) Pass ref to SideNavBase and write a test fix(side nav): Pass ref to SideNavBase and write a test Sep 10, 2024
@aaryanporwal
Copy link
Contributor Author

@huwshimi I think in the last PR we forgot to add pass the ref further down to SideNavBase component, because in Anbox we were still getting the error Functional components can not be given ref.

This PR adds it, but it also presents with a type error. It works if I replace the generic type of forwardRef in SideNavLink and SideNavBase to HTMLAnchorElement.
Screenshot 2024-09-11 at 1 07 15 PM

Does this mean if we want to use ref, we have to use a base HTML element and that we can't pass a custom functional component in SideNavLink?

Copy link
Contributor

@edlerd edlerd left a comment

Choose a reason for hiding this comment

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

LGTM

@aaryanporwal aaryanporwal merged commit 26793e5 into canonical:main Sep 12, 2024
9 checks passed
Copy link

🎉 This PR is included in version 1.2.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants