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 navigation bar highlighting to select only the active section #9252

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

Rishith25
Copy link
Contributor

@Rishith25 Rishith25 commented Nov 29, 2024

Proposed Changes

@ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

Summary by CodeRabbit

  • New Features

    • Introduced a section tracking feature in the Demography component, enhancing user interaction by maintaining the clicked section state during scrolling.
  • Bug Fixes

    • Improved logic for updating the active section based on user clicks, ensuring a more intuitive experience.
  • Changes

    • Updated the representation of phone numbers in the AssignedToObjectModel for better consistency, now including an optional phone number property.

@Rishith25 Rishith25 requested a review from a team as a code owner November 29, 2024 17:27
Copy link
Contributor

coderabbitai bot commented Nov 29, 2024

Walkthrough

The changes in the Demography component of the PatientDetailsTab introduce a new state variable, clickedSection, to track user interactions with different sections. The useEffect hook has been updated to rely on this new state for managing section visibility. Modifications to the scrollToSection function allow it to update both the clickedSection and activeSection. Additionally, the cleanup function in the useEffect has been streamlined. These updates improve the handling of user clicks and section visibility.

Changes

Files Change Summary
src/components/Patient/PatientDetailsTab/Demography.tsx Added clickedSection state variable, modified useEffect dependencies, updated scrollToSection function, and simplified cleanup function.
src/components/Patient/models.tsx Updated AssignedToObjectModel interface by adding optional phone_number property.

Assessment against linked issues

Objective Addressed Explanation
The emergency contact field should display the volunteer's primary phone number correctly. (#9244) This PR does not address the emergency contact field issue.
Selecting "Volunteer Contact" in the navigation bar should ensure only that option is highlighted. (#9244) The changes do not affect the navigation bar selection behavior.

Possibly related PRs

Suggested labels

needs review, tested, P1

Suggested reviewers

  • Jacobjeevan
  • rithviknishad
  • shivankacker

🐰 In the land where patients dwell,
A click on a section casts a spell.
With state now tracked, oh what a sight,
Navigating smoothly, all feels right!
So hop along, let changes flow,
In Demography, let interactions grow! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ef68ac0 and 3209ccc.

📒 Files selected for processing (1)
  • src/components/Patient/models.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Patient/models.tsx

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Experiment)
  • @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.

Copy link

netlify bot commented Nov 29, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 3209ccc
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/67587363ba394b00088e43e2
😎 Deploy Preview https://deploy-preview-9252--care-ohc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Rishith25
Copy link
Contributor Author

@coderabbitai Full review

Copy link
Contributor

coderabbitai bot commented Nov 29, 2024

✅ Actions performed

Full review triggered.

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: 1

🧹 Outside diff range and nitpick comments (2)
src/components/Patient/PatientDetailsTab/Demography.tsx (2)

47-47: Consider lowering the intersection threshold

The current threshold of 0.6 requires sections to be 60% visible before triggering the observer. This might lead to sections not being highlighted until significantly scrolled into view.

-      { threshold: 0.6 },
+      { threshold: 0.3 },

Line range hint 68-73: Consider adding a way to reset clicked section

Currently, once a section is clicked, the scroll-based highlighting won't work until page refresh. Consider adding a way to reset the clicked state, perhaps after a certain time delay or when clicking the same section again.

 const scrollToSection = (sectionId: string) => {
-    setClickedSection(sectionId);
+    setClickedSection((prev) => prev === sectionId ? null : sectionId);
     setActiveSection(sectionId);
     const section = document.getElementById(sectionId);
     if (section) {
       section.scrollIntoView({ behavior: "smooth" });
     }
   };
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c58de17 and 2756b94.

📒 Files selected for processing (1)
  • src/components/Patient/PatientDetailsTab/Demography.tsx (2 hunks)
🔇 Additional comments (2)
src/components/Patient/PatientDetailsTab/Demography.tsx (2)

34-34: LGTM: Good state management approach

The introduction of clickedSection state effectively separates user-initiated section selection from scroll-based activation.


41-45: Verify the fix prevents multiple section highlighting

The implementation looks correct, but let's verify that clicking "Volunteer Contact" no longer causes "Insurance Details" to be highlighted simultaneously.

Also applies to: 68-69

✅ Verification successful

Let me gather more information about the implementation to verify the fix thoroughly.


After reviewing the complete implementation, I can now provide the final response:

Fix for multiple section highlighting is correctly implemented

The implementation effectively prevents simultaneous highlighting through:

  1. The clickedSection state that blocks the IntersectionObserver from updating activeSection when a section is clicked
  2. The scrollToSection function that properly manages both states
  3. A single source of truth for section highlighting through the activeSection state
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any other instances where multiple sections might be highlighted

# Look for other places in the codebase where section highlighting is managed
rg -l "setActiveSection|scrollToSection" src/

Length of output: 103


Script:

#!/bin/bash
# Check the complete implementation in Demography.tsx
cat src/components/Patient/PatientDetailsTab/Demography.tsx

Length of output: 15192

@Jacobjeevan Jacobjeevan requested review from vigneshhari and removed request for vigneshhari December 4, 2024 08:25
@Jacobjeevan
Copy link
Contributor

Waiting for backend changes.

@nihal467
Copy link
Member

image

the phone number is not being fetched to the frontend even with backend

@Rishith25
Copy link
Contributor Author

Rishith25 commented Dec 10, 2024

image

the phone number is not being fetched to the frontend even with backend

I raised a PR in backend so it should be merged to get the patient contact number.
In frontend we have to use phone_number instead of alt_phone_number So frist the backend need to be merged in order to get the phone_number of the volunteer.

now i have changed the alt_phone_number to phone_number in frontend

@github-actions github-actions bot added the Deploy-Failed Deplyment is not showing preview label Dec 10, 2024
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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2756b94 and ef68ac0.

📒 Files selected for processing (2)
  • src/components/Patient/PatientDetailsTab/Demography.tsx (3 hunks)
  • src/components/Patient/models.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Patient/PatientDetailsTab/Demography.tsx

src/components/Patient/models.tsx Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle the Volunteer Contact Number in the patient details page
3 participants