Skip to content

Fix: click on my identities to go back#1176

Merged
Marchand-Nicolas merged 4 commits intolfglabs-dev:testnetfrom
Verifieddanny:fix-1126
Jul 29, 2025
Merged

Fix: click on my identities to go back#1176
Marchand-Nicolas merged 4 commits intolfglabs-dev:testnetfrom
Verifieddanny:fix-1126

Conversation

@Verifieddanny
Copy link
Contributor

@Verifieddanny Verifieddanny commented Jul 5, 2025

Fix Navigation Issue - Cannot Return to "My Identities" from PFP Page

Problem Description

Users were unable to navigate back to the "My Identities" page when clicking the navbar link while on the PFP page. The link appeared unresponsive, trapping users on the PFP page without a way to return to the main identities view.

fixes #1126

Root Cause Analysis

The issue was caused by a timing conflict in the mobile navigation system:

  • 📱 The <Link> component was wrapped with an onClick={handleNav} handler
  • ❌ The handleNav() function was closing the mobile menu simultaneously with navigation
  • ⚡ This created a race condition where the menu state change interfered with Next.js routing

The conflict prevented the router from completing the navigation to /identities, leaving users stuck on the current PFP page.

Solution Implemented

Key Changes:

  1. Created a dedicated handleMobileNavClick function that properly sequences operations:
const handleMobileNavClick = (href: string) => {
  setNav(false)  // Close mobile menu first
  setTimeout(() => {
    router.push(href)  // Navigate after menu closes
  }, 100)
}
  1. Replaced problematic <Link> + onClick pattern in mobile navigation:

  2. Before: <Link href="/identities"><li onClick={handleNav}>My Identities</li></Link>

  3. After: <li onClick={() => handleMobileNavClick("/identities")}>My Identities</li>

  4. Fixed all mobile navigation links:

  5. 🎯 "My Identities" → /identities

  6. 🏠 "Domains" → /

  7. 🖼️ "PFP collections" → /pfpcollections

  8. 📧 "Newsletter" → /newsletter

  9. Improved external link handling:

  10. 🌐 Uses window.open() for external URLs

  11. 📱 Properly closes mobile menu before opening external links

Files Modified:

  • components/navbar.tsx - Fixed mobile navigation timing and routing logic

Testing Scenarios

  • Navigate from PFP page → "My Identities" page (Primary fix)
  • Navigate between all internal pages via mobile menu
  • External links open correctly in new tabs
  • Mobile menu closes properly after navigation
  • Desktop navigation remains unaffected

Impact

  • 🎉 Users can now successfully return to "My Identities" from any page
  • 🔄 Restored proper navigation flow throughout the app
  • 📱 Enhanced mobile user experience
  • 🚀 Eliminated navigation dead-ends

Summary by CodeRabbit

  • Bug Fixes
    • Improved mobile navigation by ensuring links close the menu and navigate correctly.
    • Added fallback images for profile pictures and connector icons to prevent display issues.
    • Fixed profile picture update mode resetting correctly when navigating to the main identities page.

@vercel
Copy link

vercel bot commented Jul 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
app-starknet-id ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2025 8:32pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 5, 2025

"""

Walkthrough

A new useEffect hook was added to the AvailableIdentities component to reset the isUpdatingPp state when navigating to the "/identities" route, ensuring the profile picture update mode is exited on route changes or initial load. Additionally, a trailing newline was removed from components/UI/navbar.tsx without affecting functionality.

Changes

File(s) Change Summary
components/identities/availableIdentities.tsx Added useEffect to reset isUpdatingPp when route changes to or loads "/identities".
components/UI/navbar.tsx Removed trailing newline at end of file; no functional changes.

Assessment against linked issues

Objective Addressed Explanation
Fix inability to click on "My Identities" to navigate back (#1126) Reset isUpdatingPp state when navigating back to identities page.

Suggested labels

❌ Change request
"""

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • Marchand-Nicolas

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-07-25T20_32_14_416Z-debug-0.log

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 22c5612 and 1117805.

📒 Files selected for processing (1)
  • components/identities/availableIdentities.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/identities/availableIdentities.tsx
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@vercel
Copy link

vercel bot commented Jul 5, 2025

@Verifieddanny is attempting to deploy a commit to the LFG Labs Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
components/UI/navbar.tsx (1)

90-92: Apply optional chaining for cleaner code.

The static analysis tool correctly identified that this can be simplified using optional chaining.

-      const connector = getLastConnected()
-      if (connector && connector.available()) await connectWallet(connector)
+      const connector = getLastConnected()
+      if (connector?.available()) await connectWallet(connector)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 88a13ff and 30cd98e.

📒 Files selected for processing (1)
  • components/UI/navbar.tsx (12 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
components/UI/navbar.tsx

[error] 91-91: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (4)
components/UI/navbar.tsx (4)

142-150: Excellent fix for the mobile navigation timing issue!

The handleMobileNavClick function properly addresses the race condition between menu closing and navigation. The 100ms delay ensures the menu closes before navigation occurs, preventing the routing conflicts.


293-334: Mobile navigation links successfully converted to use the new handler.

The conversion from <Link> components with onClick handlers to <li> elements with the new handleMobileNavClick function is correctly implemented. This ensures consistent behavior across all mobile navigation links and external links.


218-218: Good defensive programming with fallback image source.

Adding the fallback to /placeholder.svg prevents broken images when profile pictures are undefined.


233-233: Proper fallback handling for connector icons.

The fallback value ensures the UI remains functional when connector icons are unavailable.

Copy link
Collaborator

@Marchand-Nicolas Marchand-Nicolas left a comment

Choose a reason for hiding this comment

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

It doesn't build

@Marchand-Nicolas Marchand-Nicolas added the ❌ Change request Change requested from reviewer label Jul 17, 2025
@Verifieddanny
Copy link
Contributor Author

@Marchand-Nicolas Issue Fixed

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
components/UI/navbar.tsx (2)

57-104: LGTM: Effect hooks are properly implemented

The effect hooks maintain their logic correctly. The new effect for updating lastConnector state is appropriate.

However, there's a static analysis suggestion to improve line 92:

-      if (connector && connector.available()) await connectWallet(connector)
+      if (connector?.available()) await connectWallet(connector)

143-151: LGTM: Effective solution for the mobile navigation timing issue

The handleMobileNavClick function properly addresses the race condition by closing the mobile menu before navigation. The 100ms delay ensures the menu state update completes before routing occurs.

Consider adding error handling for the navigation:

 const handleMobileNavClick = (href: string) => {
   // Close the mobile menu first
   setNav(false)
   // Small delay to ensure menu closes before navigation
   setTimeout(() => {
-    router.push(href)
+    router.push(href).catch(console.error)
   }, 100)
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 30cd98e and 11394f6.

📒 Files selected for processing (1)
  • components/UI/navbar.tsx (12 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
components/UI/navbar.tsx

[error] 92-92: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (6)
components/UI/navbar.tsx (6)

1-31: LGTM: Clean import organization and explicit type annotations

The import statements are well-organized and the explicit type annotations for FunctionComponent, StarkProfile, and Connector improve code clarity.


33-63: LGTM: Proper state management with explicit typing

The state declarations are well-structured with explicit TypeScript annotations. The new lastConnector state variable is properly typed and initialized.


106-141: LGTM: Event handlers are well-formatted and maintain correct logic

The event handlers are properly structured with consistent formatting. The logic remains intact and functions are correctly typed.


176-254: LGTM: Desktop navigation improvements with proper fallbacks

The desktop navigation maintains its <Link> component approach, which is correct since the timing issue was mobile-specific. The addition of fallback placeholders for profile pictures and connector icons improves robustness.


293-335: LGTM: Comprehensive mobile navigation fix addressing the core issue

The mobile navigation implementation correctly addresses the race condition by:

  • Replacing <Link> components with <li> elements using onClick handlers
  • Using handleMobileNavClick for internal navigation (identities, domains, pfpcollections, newsletter)
  • Properly handling external links with window.open and menu closure
  • Ensuring the mobile menu closes before any navigation action

This implementation directly fixes the issue described in the PR objectives where users couldn't navigate back to "My Identities" from the PFP page.


336-401: LGTM: Component structure and exports are properly maintained

The remaining component structure, including modals and social links, is appropriately unchanged. The export statement is correctly formatted.

@Verifieddanny
Copy link
Contributor Author

@Marchand-Nicolas Please Kindly check the updates


// Fixed function to handle mobile navigation clicks
const handleMobileNavClick = (href: string) => {
// Close the mobile menu first
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you cancel those changes, this is not the issue.
When you are on /identities (not /identities/xxx), if you edit your pfp and click "My identities", nothing will happen (because you are already on /identities.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ohh my bad, on it now

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
components/identities/availableIdentities.tsx (1)

207-213: Effect works; tiny optimisation possible

The hook correctly exits PFP-update mode when the user lands on /identities.
If you want to avoid an extra render, guard the setter so it only fires when needed:

-  if (router.pathname === "/identities" && !router.query.tokenId) {
-    setIsUpdatingPp(false)
-  }
+  if (
+    router.pathname === "/identities" &&
+    !router.query.tokenId &&
+    isUpdatingPp
+  ) {
+    setIsUpdatingPp(false);
+  }

Purely optional – current code is fine.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 11394f6 and 22c5612.

📒 Files selected for processing (2)
  • components/UI/navbar.tsx (1 hunks)
  • components/identities/availableIdentities.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • components/UI/navbar.tsx

Copy link
Collaborator

@Marchand-Nicolas Marchand-Nicolas left a comment

Choose a reason for hiding this comment

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

It's still not working, have you tested ?
If you need mroe details or need help to test please ask

Copy link
Collaborator

@Marchand-Nicolas Marchand-Nicolas left a comment

Choose a reason for hiding this comment

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

Working perfectly well done! Lgtm :D

@Marchand-Nicolas Marchand-Nicolas merged commit 5999c8b into lfglabs-dev:testnet Jul 29, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

❌ Change request Change requested from reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

I can not click on "my identities" to go back

2 participants