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: task input dropdowns #3152

Merged
merged 2 commits into from
Oct 17, 2024

Conversation

BirushaNdegeya
Copy link
Contributor

@BirushaNdegeya BirushaNdegeya commented Oct 16, 2024

Description

Please include a summary of the changes and the related issue.

Type of Change

  • ✅ Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • ✅ My code follows the style guidelines of this project
  • ✅ I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • ✅ My changes generate no new warnings

Previous screenshots

Screenshot from 2024-10-16 10-59-50

Please add here videos or images of previous status

Current screenshots

Please add here videos or images of previous status
Screenshot from 2024-10-16 10-49-41

Summary by CodeRabbit

  • New Features

    • Enhanced dropdown components with a new isEpic prop for better task status representation.
    • Added fixed height and horizontal scrolling to dropdown options for improved usability.
  • Style

    • Improved formatting and readability of the AuthUserTaskInput component.
    • Updated styles for dropdown components to enhance visual consistency.

@CLAassistant
Copy link

CLAassistant commented Oct 16, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

coderabbitai bot commented Oct 16, 2024

Walkthrough

The changes involve formatting adjustments to the AuthUserTaskInput component for improved readability and enhancements to the task-status.tsx file. Specifically, the dropdown components have been updated to include a fixed maximum height and horizontal scrolling, and a new prop isEpic has been introduced in the TaskStatus component. The overall structure and functionality of the components remain unchanged.

Changes

File Path Change Summary
apps/web/lib/features/auth-user-task-input.tsx Formatting adjustments for readability, including improved alignment and indentation. Consolidated import statements into a single line and reformatted the JSX structure.
apps/web/lib/features/task/task-status.tsx Added fixed maximum height and horizontal scrolling to dropdown options. Introduced isEpic prop in TaskStatus, with minor adjustments to props in StatusDropdown and MultipleStatusDropdown.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant StatusDropdown
    participant TaskStatus

    User->>StatusDropdown: Selects status
    StatusDropdown->>TaskStatus: Passes selected status and isEpic
    TaskStatus->>User: Displays updated task status
Loading

🐇 "In code we hop, with changes so bright,
Formatting and props, all done just right.
Dropdowns now scroll, with height set to play,
A new prop for epics, hip-hip-hooray!
With every small tweak, our features take flight,
A dance of the code, in the soft moonlight." 🌙


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

@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 (3)
apps/web/lib/features/auth-user-task-input.tsx (2)

32-57: Approved with suggestion: Dropdown component formatting

The formatting changes to the dropdown components improve code readability. The consistent indentation and line breaks make the component structure clearer.

Consider using template literals for long className strings to improve readability further. For example:

- className="lg:max-w-[170px] w-full text-xs"
+ className={`
+   lg:max-w-[170px]
+   w-full
+   text-xs
+ `}

This approach can make long className strings more manageable and easier to read.


Line range hint 58-67: Consider removing commented-out code

The file contains a block of commented-out code. It's generally better to remove unused code entirely and rely on version control systems for tracking changes and history.

Consider removing the commented-out code block to improve code cleanliness. If this code might be needed in the future, it's better to keep it in version control history rather than as comments in the current file.

apps/web/lib/features/task/task-status.tsx (1)

Line range hint 1226-1226: Good use of max-height and scrolling, but reconsider hiding the scrollbar

The implementation of max-height and vertical scrolling in the MultipleStatusDropdown component is a good approach. It allows the dropdown to accommodate varying amounts of content while maintaining a reasonable size.

However, hiding the scrollbar with scrollbar-hide might affect usability, as users may not realize they can scroll if there's more content. Consider showing a styled scrollbar instead. You could use CSS to style the scrollbar for better visual integration:

.styled-scrollbar {
  scrollbar-width: thin;
  scrollbar-color: rgba(155, 155, 155, 0.5) transparent;
}

.styled-scrollbar::-webkit-scrollbar {
  width: 6px;
}

.styled-scrollbar::-webkit-scrollbar-thumb {
  background-color: rgba(155, 155, 155, 0.5);
  border-radius: 3px;
}

Then, replace scrollbar-hide with styled-scrollbar in your className.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e703750 and 80b3ef4.

📒 Files selected for processing (2)
  • apps/web/lib/features/auth-user-task-input.tsx (2 hunks)
  • apps/web/lib/features/task/task-status.tsx (1 hunks)
🧰 Additional context used
🔇 Additional comments (6)
apps/web/lib/features/auth-user-task-input.tsx (4)

10-10: LGTM: Import statement consolidation

The consolidation of import statements for task-related components improves code readability without changing functionality.


14-16: Approved: Consistent formatting

The added spaces improve code readability and maintain consistent formatting throughout the component.


18-30: LGTM: Improved JSX formatting

The changes to the JSX structure improve code readability by properly indenting nested elements. This makes the component structure easier to understand at a glance.


Line range hint 1-70: Verify alignment with PR objectives

The changes in this file are primarily formatting improvements, which enhance code readability. However, the PR objectives mentioned fixing task input dropdowns, but no such fixes are evident in this file.

Please clarify if there are additional changes related to fixing task input dropdowns that are not reflected in this file. If the fix is implemented elsewhere, consider updating the PR description to accurately reflect the changes made.

To verify if there are any other relevant changes, you can run the following script:

This will search for any mentions of "dropdown" or "task input" in TypeScript and TSX files, excluding the current file.

apps/web/lib/features/task/task-status.tsx (2)

Line range hint 1-1250: Consider splitting this file for improved maintainability

While the changes made to this file are generally positive and improve the component's functionality, it's worth noting that this file is quite large and contains multiple components and utility functions.

To improve maintainability and make the codebase easier to navigate, consider splitting this file into smaller, more focused files. For example:

  1. Create a separate file for each main component (StatusDropdown, MultipleStatusDropdown, TaskStatus, etc.).
  2. Group related utility functions and hooks into their own files (e.g., useTaskStatusValue, useTaskPrioritiesValue, etc.).
  3. Create an index file to export all components and utilities, maintaining the current import structure for other parts of the application.

This refactoring would make it easier to understand, maintain, and test each component individually. It would also improve code reusability and potentially reduce merge conflicts in collaborative development.

To help with this refactoring, you can use the following command to identify the main components and functions that could be separated:

#!/bin/bash
# List all exported functions and components in the file
rg --type typescript --type tsx "^export (function|const) \w+" apps/web/lib/features/task/task-status.tsx

This will give you a list of the main exports, which can guide your refactoring process.


Line range hint 1-1250: Clarify the purpose and usage of the new isEpic prop

A new prop isEpic has been added to the TaskStatus component and is being passed down in various places throughout the file. While the implementation seems consistent, it's not immediately clear how this prop affects the component's behavior or appearance.

Could you provide more context on the purpose of the isEpic prop? Specifically:

  1. How does it change the rendering or functionality of the TaskStatus component?
  2. Are there any specific styles or behaviors associated with epic tasks?
  3. Is there any documentation that needs to be updated to reflect this new property?

Additionally, to ensure this change is implemented correctly across the codebase, you may want to run the following command to check for any inconsistencies:

This will help identify any places where the isEpic prop might need to be added or where its handling might be inconsistent.

Comment on lines 1078 to 1079
className="p-4 md:p-4 shadow-xlcard dark:shadow-lgcard-white dark:bg-[#1B1D22] dark:border dark:border-[#FFFFFF33] flex flex-col gap-2.5 h-[206px] overflow-x-scroll"
>
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider using max-height and adding vertical scrolling

The addition of a fixed height (206px) and horizontal scrolling improves the dropdown's usability. However, a fixed height might not be optimal for all screen sizes and could potentially cut off content.

Consider the following improvements:

  1. Use max-height instead of a fixed height to accommodate varying content lengths.
  2. Add vertical scrolling to ensure all options are accessible, especially on smaller screens.
  3. Implement responsive design to adjust the max-height based on screen size.

Here's a suggested modification:

- className="p-4 md:p-4 shadow-xlcard dark:shadow-lgcard-white dark:bg-[#1B1D22] dark:border dark:border-[#FFFFFF33] flex flex-col gap-2.5 h-[206px] overflow-x-scroll"
+ className="p-4 md:p-4 shadow-xlcard dark:shadow-lgcard-white dark:bg-[#1B1D22] dark:border dark:border-[#FFFFFF33] flex flex-col gap-2.5 max-h-[300px] overflow-y-auto overflow-x-hidden"

This change allows the dropdown to grow up to 300px in height (adjustable as needed) and adds vertical scrolling while removing horizontal scrolling.

📝 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
className="p-4 md:p-4 shadow-xlcard dark:shadow-lgcard-white dark:bg-[#1B1D22] dark:border dark:border-[#FFFFFF33] flex flex-col gap-2.5 h-[206px] overflow-x-scroll"
>
className="p-4 md:p-4 shadow-xlcard dark:shadow-lgcard-white dark:bg-[#1B1D22] dark:border dark:border-[#FFFFFF33] flex flex-col gap-2.5 max-h-[300px] overflow-y-auto overflow-x-hidden"
>

Copy link

@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 (4)
apps/web/lib/features/task/task-status.tsx (4)

1078-1079: Improved dropdown menu styling and scrolling behavior

The changes to the Card component's className enhance the dropdown menu's appearance and functionality:

  1. Added max-h-[206px] to limit the maximum height of the dropdown.
  2. Added overflow-x-scroll to enable horizontal scrolling when content exceeds the width.

These changes improve the user experience by preventing the dropdown from becoming too tall and allowing users to scroll horizontally if needed. However, there are a couple of points to consider:

  1. Using a fixed max-height might not be ideal for all screen sizes. Consider using a responsive approach or CSS variables for better flexibility.
  2. overflow-x-scroll might not be necessary unless you expect the content to exceed the width frequently. If not, you could remove it or change it to overflow-x-auto.

Consider the following improvements:

- className="p-4 md:p-4 shadow-xlcard dark:shadow-lgcard-white dark:bg-[#1B1D22] dark:border dark:border-[#FFFFFF33] flex flex-col gap-2.5 max-h-[206px] overflow-x-scroll"
+ className="p-4 md:p-4 shadow-xlcard dark:shadow-lgcard-white dark:bg-[#1B1D22] dark:border dark:border-[#FFFFFF33] flex flex-col gap-2.5 max-h-[50vh] overflow-y-auto overflow-x-hidden"

This change uses a relative max-height (50% of the viewport height) and changes the overflow behavior to be more appropriate for most use cases.


Line range hint 1031-1189: Consider refactoring StatusDropdown for improved maintainability

The StatusDropdown component is quite complex and handles many different cases. While the recent changes don't introduce any issues, there are some suggestions to improve the overall code quality and maintainability:

  1. Extract smaller components: The component could benefit from being broken down into smaller, more focused components. For example, the Listbox.Option rendering could be extracted into a separate component.

  2. Use custom hooks: Consider extracting some of the logic (e.g., handling multiple selection) into custom hooks to improve reusability and reduce the complexity of the main component.

  3. Consistent naming: Ensure consistent naming conventions throughout the component. For example, current_value uses snake_case while the rest of the variables use camelCase.

  4. Prop types: Consider using TypeScript or PropTypes to more strictly define the expected props and their types.

  5. Accessibility: Ensure that the dropdown is fully accessible, including keyboard navigation and proper ARIA attributes.

Here's a small example of how you could start refactoring:

// Extract this into a separate component
const DropdownItem = ({ item, isSelected, onSelect, onRemove }) => (
  <Listbox.Option value={item.value || item.name} as={Fragment}>
    <li className="cursor-pointer outline-none relative">
      <TaskStatus
        showIcon={showIcon}
        {...item}
        cheched={isSelected}
        className={/* ... */}
      />
      {isSelected && (
        <button
          onClick={onRemove}
          className="absolute top-2.5 right-2 h-4 w-4 bg-light--theme-light dark:bg-dark--theme-light"
        >
          <XMarkIcon className="text-dark dark:text-white" height={16} width={16} />
        </button>
      )}
    </li>
  </Listbox.Option>
);

// Use in the main component
{items.map((item) => (
  <DropdownItem
    key={item.value || item.name}
    item={item}
    isSelected={/* ... */}
    onSelect={/* ... */}
    onRemove={/* ... */}
  />
))}

This refactoring would make the main component more readable and easier to maintain.


Line range hint 1191-1321: Consider merging StatusDropdown and MultipleStatusDropdown components

The MultipleStatusDropdown component is very similar to the StatusDropdown component, with the main difference being support for multiple selection. This duplication suggests an opportunity for code reuse and simplification:

  1. Merge components: Consider combining StatusDropdown and MultipleStatusDropdown into a single, more flexible component that can handle both single and multiple selection modes.

  2. Prop consistency: Ensure that all props are consistently named and used between the two components. For example, showIssueLabels is defined in the props but not used in MultipleStatusDropdown.

  3. DRY principle: There's repeated code for rendering the Listbox and its options. This could be extracted into a shared function or component.

  4. Type safety: Use TypeScript to ensure type safety and improve maintainability, especially for complex prop structures.

Here's an example of how you could start refactoring:

interface StatusDropdownProps<T extends TStatusItem> {
  value: T | T[] | undefined;
  onChange: (value: string | string[]) => void;
  items: T[];
  multiple?: boolean;
  // ... other props
}

function StatusDropdown<T extends TStatusItem>({
  value,
  onChange,
  items,
  multiple = false,
  // ... other props
}: StatusDropdownProps<T>) {
  // Shared logic here

  return (
    <Listbox
      value={multiple ? (value as T[]) : (value as T)}
      onChange={onChange}
      multiple={multiple}
    >
      {/* Shared rendering logic */}
    </Listbox>
  );
}

// Usage
<StatusDropdown multiple={true} /* ... other props */ />
<StatusDropdown multiple={false} /* ... other props */ />

This approach would reduce code duplication and make the component more flexible and easier to maintain.


Line range hint 1-1321: Consider refactoring the file for improved organization and maintainability

While the recent changes don't introduce any significant issues, the overall structure of this file could be improved:

  1. File splitting: This file is quite long and handles multiple concerns. Consider splitting it into smaller, more focused files. For example:

    • TaskStatusDropdown.tsx
    • TaskPriorityDropdown.tsx
    • TaskLabelDropdown.tsx
    • StatusDropdown.tsx (generic component)
    • useTaskStatus.ts (custom hooks)
  2. Component organization: Group related components and hooks together. This will make it easier to understand the relationships between different parts of the code.

  3. Consistent naming: Ensure consistent naming conventions across components and functions. For example, some use PascalCase (e.g., TaskStatus), while others use camelCase (e.g., useTaskStatusValue).

  4. Performance optimization: For large lists, consider implementing virtualization to improve performance. Libraries like react-window can help with this.

  5. Prop drilling: There's a lot of prop drilling happening in some components. Consider using React Context or a state management library for deeply nested props.

  6. Error handling: Add proper error handling and fallback UI for cases where data might be undefined or loading.

  7. Testing: Given the complexity of these components, it would be beneficial to add unit and integration tests to ensure reliability and ease of refactoring.

To implement these suggestions:

  1. Create new files for each major component and move the code accordingly.
  2. Use a barrel file (index.ts) to simplify imports.
  3. Implement React Context for frequently used props:
// TaskContext.tsx
import React, { createContext, useContext } from 'react';

const TaskContext = createContext(null);

export const TaskProvider = ({ children, ...value }) => (
  <TaskContext.Provider value={value}>{children}</TaskContext.Provider>
);

export const useTaskContext = () => useContext(TaskContext);

// Usage
import { TaskProvider, useTaskContext } from './TaskContext';

const ParentComponent = () => (
  <TaskProvider value={/* ... */}>
    <ChildComponents />
  </TaskProvider>
);

const ChildComponent = () => {
  const taskContext = useTaskContext();
  // Use context values
};

These changes will significantly improve the maintainability and readability of your code.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 80b3ef4 and d3d8072.

📒 Files selected for processing (1)
  • apps/web/lib/features/task/task-status.tsx (1 hunks)
🧰 Additional context used

@Cedric921 Cedric921 self-requested a review October 16, 2024 13:15
@Cedric921 Cedric921 added this to the v0.2.0 milestone Oct 16, 2024
@Cedric921 Cedric921 requested a review from evereq October 17, 2024 20:53
@evereq evereq merged commit 27c6fb8 into ever-co:develop Oct 17, 2024
11 checks passed
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.

4 participants