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

Closed

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

  • Bug Fixes

    • Improved section scrolling behavior in patient details view
    • Fixed emergency contact phone number display
  • Refactor

    • Enhanced section tracking mechanism to prevent unintended section changes

@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 pull request modifies the Demography component in the patient details tab, introducing a new state variable clickedSection to manage section navigation. The changes improve the component's scrolling behavior by preventing automatic section updates when a user manually selects a section. Additionally, the emergency contact section now references the primary phone number instead of an alternative phone number, addressing potential data display issues.

Changes

File Change Summary
src/components/Patient/PatientDetailsTab/Demography.tsx - Added clickedSection state variable
- Updated scrollToSection method to set clicked and active sections
- Modified emergency contact to use phone_number instead of alt_phone_number

Assessment against linked issues

Objective Addressed Explanation
Display volunteer's primary phone number [#9244]
Prevent simultaneous section highlighting Requires further investigation of navigation bar behavior

Possibly related PRs

Suggested reviewers

  • Jacobjeevan

Poem

🐰 A rabbit's tale of scrolling grace,
Where sections dance with gentle pace
No more confusion, clear and bright
The patient's details now take flight!
Code hops along, with sections clear 🏥


📜 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 36b4c2d and 3de864b.

📒 Files selected for processing (1)
  • src/components/Patient/PatientDetailsTab/Demography.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Patient/PatientDetailsTab/Demography.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. (Beta)
  • @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 3de864b
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/676fa59bf5b3ac000874c161
😎 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 Outdated Show resolved Hide resolved
@nihal467
Copy link
Member

LGTM

@Rishith25
Copy link
Contributor Author

@Jacobjeevan I will update it by tomorrow.

Copy link

👋 Hi, @Rishith25,
Conflicts have been detected against the base branch. Please rebase your branch against the base branch.


This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there.

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Dec 31, 2024
@rithviknishad
Copy link
Member

no longer relevant in new architecture

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.

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