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

Update Sidebar.tsx #1

Merged
merged 1 commit into from
Nov 26, 2024
Merged

Update Sidebar.tsx #1

merged 1 commit into from
Nov 26, 2024

Conversation

parthikjadav
Copy link
Owner

@parthikjadav parthikjadav commented Nov 26, 2024

fixed this issue asyncapi#1109

Description

Changes proposed in this pull request:

The anchor link for a message in the sidebar does not work as expected when message.name() and message.id() differ.

Expected result
Clicking on a message in the sidebar should set the correct hash in the URL and scroll the message into view.

Actual result
The anchor link only works if message.name() and message.id() are identical.
If message.name() is not provided, the hash becomes #message-undefined.

before
image

after
image

Summary by Sourcery

Bug Fixes:

  • Fix the issue where the anchor link in the sidebar did not work correctly when message.name() and message.id() differed by changing the href attribute to use message.id().

Copy link

sourcery-ai bot commented Nov 26, 2024

Reviewer's Guide by Sourcery

The PR fixes an issue with sidebar message links by updating the anchor href attribute to use message.id() instead of message.name(). This change ensures that the anchor links work correctly regardless of whether message.name() is defined or different from message.id().

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Updated anchor link generation in sidebar message list
  • Changed href attribute to use message.id() instead of message.name()
  • Added explanatory comment about the fix for undefined name issue
library/src/containers/Sidebar/Sidebar.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @parthikjadav - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -38,10 +38,11 @@ export const Sidebar: React.FunctionComponent = () => {
</a>
<ul className="text-sm mt-2">
{messages.map((message, index) => (
<li key={`menu-message-list-${message.name() ?? index}`}>
<li key={`menu-message-list-${message.name() ?? index}`}>
Copy link

Choose a reason for hiding this comment

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

suggestion (bug_risk): Consider using message.id() instead of message.name() in the key prop for consistency

Since message.name() was replaced with message.id() in the href to fix undefined values, the same change should be applied to the key prop to maintain consistency and prevent potential React reconciliation issues.

       </a>
       <ul className="text-sm mt-2">
         {messages.map((message, index) => (
          <li key={`menu-message-list-${message.id() ?? index}`}>

@parthikjadav parthikjadav merged commit 41f5bad into master Nov 26, 2024
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.

1 participant