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 NavLink onClick errors when disabled #1453

Merged
merged 5 commits into from
Mar 3, 2022
Merged

Conversation

felixjung
Copy link
Collaborator

@felixjung felixjung commented Feb 27, 2022

Purpose

When using NavLink and setting disabled={true}, the onClick behavior causes a runtime error because React does not remove the onClick prop, which has the value false. Instead the prop is executed as a function with .apply() causing the runtime error, which is not defined on a boolean.

Next.js warns about this in the development console.

Approach and changes

Apply the fix recommended by Next.js so that the onClick prop is undefined instead of false.

Definition of done

  • Development completed
  • Reviewers assigned
  • Unit and integration tests
  • Meets minimum browser support
  • Meets accessibility requirements

When using `NavLink` and setting `disabled={true}`, the onClick behavior causes a runtime error because React does not remove the `onClick` prop, which has the value `false`. Instead the prop is executed as a function with `.apply()` causing the runtime error, which is not defined on a boolean.

Next.js warns about this in the development console.
@felixjung felixjung requested a review from a team as a code owner February 27, 2022 17:22
@felixjung felixjung requested review from amelako and removed request for a team February 27, 2022 17:22
@changeset-bot
Copy link

changeset-bot bot commented Feb 27, 2022

🦋 Changeset detected

Latest commit: ae08668

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sumup/circuit-ui Patch

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

@vercel
Copy link

vercel bot commented Feb 27, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/sumup/oss-circuit-ui/A9fJYF9U8b2GRy5N7f4hebAxRxEh
✅ Preview: https://oss-circuit-ui-git-fix-navitem-onclick-sumup.vercel.app

@felixjung felixjung marked this pull request as draft February 27, 2022 17:22
@felixjung
Copy link
Collaborator Author

Needs a unit test and changset.

Copy link
Member

@connor-baer connor-baer left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

This component is kinda deprecated, where is it being used?

@felixjung
Copy link
Collaborator Author

We are using it in the example app for authentication integration.

@felixjung felixjung marked this pull request as ready for review February 28, 2022 10:34
@codecov
Copy link

codecov bot commented Feb 28, 2022

Codecov Report

Merging #1453 (ae08668) into main (655e768) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1453   +/-   ##
=======================================
  Coverage   92.20%   92.20%           
=======================================
  Files         195      195           
  Lines        3992     3992           
  Branches     1260     1260           
=======================================
  Hits         3681     3681           
  Misses        292      292           
  Partials       19       19           
Impacted Files Coverage Δ
.../components/Sidebar/components/NavItem/NavItem.tsx 100.00% <100.00%> (ø)

Copy link
Member

@connor-baer connor-baer left a comment

Choose a reason for hiding this comment

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

We are using it in the example app for authentication integration.

Could you switch to the SideNavigation or the TopNavigation instead?

Co-authored-by: Connor Bär <connor-baer@users.noreply.github.com>
@felixjung felixjung enabled auto-merge (squash) February 28, 2022 20:33
@connor-baer connor-baer merged commit 21a5d90 into main Mar 3, 2022
@connor-baer connor-baer deleted the fix-navitem-onclick branch March 3, 2022 14:28
@github-actions github-actions bot mentioned this pull request Mar 3, 2022
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.

2 participants