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

Fixed scroll issue in shifting in facilities. #9268

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

Conversation

Jeffrin2005
Copy link

@Jeffrin2005 Jeffrin2005 commented Dec 2, 2024

Proposed Changes

scroll_bar1.mp4

@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

Release Notes

  • New Features

    • Introduced a ScrollableColumn component for enhanced vertical scrolling and layout management.
  • Improvements

    • Adjusted layout and alignment in the KanbanBoard and KanbanSection components for better user experience.
  • Dependency Updates

    • Updated the @radix-ui/react-scroll-area dependency to version 1.2.1 for improved functionality.

@Jeffrin2005 Jeffrin2005 requested a review from a team as a code owner December 2, 2024 07:40
Copy link
Contributor

coderabbitai bot commented Dec 2, 2024

Walkthrough

A new React functional component named ScrollableColumn has been added to the project, allowing for vertical scrolling of its content within a defined height. Modifications to the KanbanBoard and KanbanSection components enhance layout and scrolling behavior. Additionally, the .gitattributes file has been updated, and a dependency in package.json has been upgraded. These changes collectively aim to improve user interface interactions and maintain code organization.

Changes

File Change Summary
src/CAREUI/display/ScrollableColumn.tsx Introduced ScrollableColumn component with props for title and children, enabling vertical scrolling.
src/components/Kanban/Board.tsx Modified KanbanBoard and KanbanSection components for layout adjustments and scrolling behavior.
.gitattributes Updated file with new entries for text normalization and binary file handling.
package.json Updated dependency version for @radix-ui/react-scroll-area from ^1.2.0 to ^1.2.1.

Assessment against linked issues

Objective Addressed Explanation
Separate scroll for each field (Issue #7487)

Possibly related issues

Suggested labels

needs review, tested

Suggested reviewers

  • rithviknishad
  • shivankacker

Poem

🐰 In a column that scrolls, oh what a sight,
With titles that gleam and children in flight.
Kanban boards dance, aligned just so,
A smoother experience, watch it all flow!
With updates and tweaks, our UI's a delight,
Hopping along, everything feels just right! 🌟


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f555c30 and 1cb7131.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json

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 Dec 2, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 1cb7131
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/67582a73cc32990008498e86
😎 Deploy Preview https://deploy-preview-9268--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.

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

🧹 Outside diff range and nitpick comments (3)
src/CAREUI/display/ScrollableColumn.tsx (1)

4-7: Add JSDoc documentation for the interface

Consider adding TypeScript documentation to improve code maintainability and IDE support.

+/**
+ * Props for the ScrollableColumn component
+ * @property {string} title - The title displayed at the top of the column
+ * @property {React.ReactNode} children - The content to be displayed in the scrollable area
+ */
interface ScrollableColumnProps {
  title: string;
  children: React.ReactNode;
}
src/components/Kanban/Board.tsx (2)

160-163: Consider using ResizeObserver for dynamic height calculation

The hard-coded height calculation h-[calc(100vh-180px)] might not work well across different screen sizes and layouts. Consider using ResizeObserver for dynamic height calculation.

const sectionRef = useRef<HTMLDivElement>(null);
const [sectionHeight, setSectionHeight] = useState("calc(100vh - 180px)");

useEffect(() => {
  const resizeObserver = new ResizeObserver((entries) => {
    const containerHeight = entries[0].contentRect.height;
    setSectionHeight(`${containerHeight}px`);
  });
  
  if (sectionRef.current) {
    resizeObserver.observe(sectionRef.current);
  }
  
  return () => resizeObserver.disconnect();
}, []);

148-148: Consider using CSS Grid for responsive layout

The fixed width w-[300px] might not be optimal for all screen sizes. Consider using CSS Grid for a more responsive layout.

-className="relative mr-2 w-[300px] shrink-0 rounded-xl bg-secondary-200"
+className="relative mr-2 min-w-[300px] max-w-[400px] flex-1 rounded-xl bg-secondary-200"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f76c625 and fcaf7f5.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • src/CAREUI/display/ScrollableColumn.tsx (1 hunks)
  • src/components/Kanban/Board.tsx (4 hunks)
🔇 Additional comments (1)
src/components/Kanban/Board.tsx (1)

39-39: Verify the impact of alignment change

The change from items-end to items-center in the flex container might affect the visual alignment of elements. Please ensure this change doesn't create any UI inconsistencies.

✅ Verification successful

Alignment change is consistent with design patterns

The change from items-end to items-center in the flex container aligns with the codebase's design patterns. The search results show that items-center is widely used throughout the application for vertically centering content in flex containers, particularly in responsive layouts with md:flex-row breakpoints. This change maintains consistency with the established UI patterns.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other components that might be affected by this alignment change
rg "items-end|items-center" --type tsx

Length of output: 68


Script:

#!/bin/bash
# Search for Tailwind alignment classes in all files, not just tsx
rg "items-end|items-center" -A 2 -B 2

Length of output: 70445

Comment on lines 14 to 21
<div
style={{
height: "400px",
overflowY: "auto",
border: "1px solid #ccc",
margin: "10px",
}}
>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Make the component more flexible and accessible

The component could benefit from the following improvements:

  1. Allow customizable height through props
  2. Add ARIA attributes for better accessibility
  3. Support custom styling through className prop
 <div
+  role="region"
+  aria-label={title}
   style={{
-    height: "400px",
+    height: props.height || "400px",
     overflowY: "auto",
     border: "1px solid #ccc",
     margin: "10px",
+    ...props.style,
   }}
+  className={props.className}
 >

Update the props interface accordingly:

interface ScrollableColumnProps {
  title: string;
  children: React.ReactNode;
  height?: string;
  style?: React.CSSProperties;
  className?: string;
}

Comment on lines 60 to 66
<div
className="h-full overflow-scroll"
ref={board}
style={{
overflow: "hidden",
}}
>
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Resolve conflicting overflow styles

There's a potential issue with conflicting overflow styles:

  • Line 61 sets overflow-scroll
  • Line 64 overrides it with overflow: hidden

This might affect the intended scrolling behavior.

 <div
-  className="h-full overflow-scroll"
+  className="h-full overflow-x-auto overflow-y-hidden"
   ref={board}
-  style={{
-    overflow: "hidden",
-  }}
 >
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div
className="h-full overflow-scroll"
ref={board}
style={{
overflow: "hidden",
}}
>
<div
className="h-full overflow-x-auto overflow-y-hidden"
ref={board}
>

@Jeffrin2005 Jeffrin2005 changed the title Fixed scroll issue in shifting in facilities. Closes #7487 Fixed scroll issue in shifting in facilities. Dec 2, 2024
Comment on lines 2 to 21
import React from "react";

interface ScrollableColumnProps {
title: string;
children: React.ReactNode;
}

const ScrollableColumn: React.FC<ScrollableColumnProps> = ({
title,
children,
}) => {
return (
<div
style={{
height: "400px",
overflowY: "auto",
border: "1px solid #ccc",
margin: "10px",
}}
>
Copy link
Member

Choose a reason for hiding this comment

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

  1. Let's use shadcn's ScrollArea instead of custom building it https://ui.shadcn.com/docs/components/scroll-area

  2. Since this is a tailwindcss based project, we do not use css styles if tailwind classes can do it.

Copy link
Member

Choose a reason for hiding this comment

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

this file seems unnecessary

Copy link
Member

Choose a reason for hiding this comment

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

#9223 has solved issues with line endings on windows. Ensure proper line endings by using latest develop branch.

Copy link
Member

@shivankacker shivankacker left a comment

Choose a reason for hiding this comment

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

I can see some offset towards the left in cards. Can you prevent that?

In this image, the board on the left has offset. The right one is correct. Happening due to the scrollbar taking space
Screenshot 2024-12-03 at 4 17 23 PM

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

🧹 Outside diff range and nitpick comments (2)
src/components/ui/scroll-area.tsx (2)

6-6: Add JSDoc documentation for better maintainability

Consider adding JSDoc documentation to describe the component's purpose, props, and usage examples.

+/**
+ * A customizable scroll area component that provides a consistent scrolling experience
+ * across different browsers and platforms.
+ *
+ * @component
+ * @example
+ * ```tsx
+ * <ScrollArea className="h-[200px]">
+ *   <div>Scrollable content here</div>
+ * </ScrollArea>
+ * ```
+ */
const ScrollArea = React.forwardRef<

24-44: Consider improving type safety for orientation prop

The implementation looks great with proper touch handling and dark mode support. Consider enhancing type safety for the orientation prop.

+type ScrollBarOrientation = "vertical" | "horizontal";
+
 const ScrollBar = React.forwardRef<
   React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
-  React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>
+  React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar> & {
+    orientation?: ScrollBarOrientation;
+  }
 >(({ className, orientation = "vertical", ...props }, ref) => (
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between fcaf7f5 and 9a6a1d9.

📒 Files selected for processing (3)
  • .gitattributes (1 hunks)
  • src/components/Kanban/Board.tsx (4 hunks)
  • src/components/ui/scroll-area.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .gitattributes
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Kanban/Board.tsx
🔇 Additional comments (4)
src/components/ui/scroll-area.tsx (4)

1-4: LGTM! Good choice of dependencies

The use of Radix UI primitives is excellent for ensuring accessibility and consistent behavior across browsers. The imports are well-organized and include all necessary dependencies.


6-22: LGTM! Well-structured ScrollArea implementation

The component is well-implemented with proper TypeScript types, ref forwarding, and className handling. The use of Radix UI primitives ensures good accessibility and consistent behavior.


46-46: LGTM! Clean exports

The named exports are well-organized and support tree-shaking.


1-46: Verify integration with Kanban board components

The ScrollArea component looks well-implemented for solving the scroll issues. Let's verify its integration with the Kanban board components.

@github-actions github-actions bot added the Deploy-Failed Deplyment is not showing preview label Dec 4, 2024
@sainak sainak removed the Deploy-Failed Deplyment is not showing preview label Dec 5, 2024
Copy link

github-actions bot commented Dec 5, 2024

👋 Hi, @Jeffrin2005,
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 5, 2024
@github-actions github-actions bot added merge conflict pull requests with merge conflict and removed merge conflict pull requests with merge conflict labels Dec 6, 2024
Copy link

github-actions bot commented Dec 6, 2024

👋 Hi, @Jeffrin2005,
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 removed the merge conflict pull requests with merge conflict label Dec 9, 2024
@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Dec 12, 2024
Copy link

👋 Hi, @Jeffrin2005,
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes required merge conflict pull requests with merge conflict
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scroll issue in shifting in facilities.
4 participants