Skip to content

[WEB-2725] chore: app sidebar add issue button improvement#5921

Merged
pushya22 merged 1 commit intopreviewfrom
chore-app-sidebar-button-improvement
Oct 29, 2024
Merged

[WEB-2725] chore: app sidebar add issue button improvement#5921
pushya22 merged 1 commit intopreviewfrom
chore-app-sidebar-button-improvement

Conversation

@anmolsinghbhatia
Copy link
Collaborator

@anmolsinghbhatia anmolsinghbhatia commented Oct 28, 2024

Changes:

This PR improves the functionality of adding an issue from the app sidebar. Previously, the entire card was not clickable; necessary changes have been made to ensure the card is fully interactive now.

Reference:

[WEB-2725]

Summary by CodeRabbit

  • New Features

    • Improved accessibility by changing the issue creation action from a div to a semantically correct button.
    • Added a "New issue" button with an icon, enhancing user interaction.
  • Bug Fixes

    • Adjusted button styling to indicate disabled states, improving user experience.
  • Refactor

    • Streamlined the component's structure for better usability.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 28, 2024

Walkthrough

The changes in this pull request focus on the SidebarQuickActions component within the quick-actions.tsx file. The primary modification involves changing a div element to a button element for opening the issue creation modal, enhancing accessibility. The button now features a type="button" attribute, updated class names, and conditional rendering for an icon and label based on the sidebar's state. Additionally, the styling reflects the button's disabled state. A previously commented-out button for drafting issues has been removed.

Changes

File Path Change Summary
web/core/components/workspace/sidebar/quick-actions.tsx Changed div to button for issue creation, added type="button", updated class names, adjusted styling for disabled state, and removed commented-out draft button.

Possibly related PRs

  • [WEB-2344] fix: quick action hover #5449: This PR addresses hover functionality for quick actions, which is directly related to the changes made in the SidebarQuickActions component of the main PR, enhancing user interaction with quick action buttons.
  • [WEB-2715] fix: draft issue type update outside click #5902: This PR focuses on improving the handling of draft issue forms, which may involve similar user interaction patterns as the button changes in the main PR, particularly regarding modal interactions and user experience.

Suggested labels

🎨UI / UX

Suggested reviewers

  • sriramveeraghanta
  • SatishGandham

🐰 In the sidebar where quick actions dwell,
A button now shines, oh, what a swell!
With a click, new issues will bloom,
Accessibility's here, banishing gloom.
So hop on, dear friend, let’s create with glee,
For every new issue, there’s a button for thee! 🌟


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.

@anmolsinghbhatia anmolsinghbhatia marked this pull request as ready for review October 28, 2024 12:58
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 (2)
web/core/components/workspace/sidebar/quick-actions.tsx (2)

79-84: Standardize size utility classes

The component mixes different size utilities. Consider standardizing to the newer size- utilities for consistency.

 className={cn(
-  "relative flex flex-shrink-0 flex-grow items-center gap-2 h-8 text-custom-sidebar-text-300 rounded outline-none hover:bg-custom-sidebar-background-90",
+  "relative flex flex-shrink-0 flex-grow items-center gap-2 size-8 text-custom-sidebar-text-300 rounded outline-none hover:bg-custom-sidebar-background-90",
   {
     "justify-center size-8 aspect-square": isSidebarCollapsed,
     "cursor-not-allowed opacity-50 ": disabled,
     "px-3 border-[0.5px] border-custom-sidebar-border-300": !isSidebarCollapsed,

Line range hint 17-22: Clean up unused state and draft-related code

Several state variables and related code for the removed draft functionality can be cleaned up:

  1. Remove unused states:
-  const [isDraftIssueModalOpen, setIsDraftIssueModalOpen] = useState(false);
-  const [isDraftButtonOpen, setIsDraftButtonOpen] = useState(false);
-  const timeoutRef = useRef<any>();
  1. Remove the CreateUpdateIssueModal component instance and related code since it's only used for drafts.

  2. Remove the useLocalStorage hook usage and related draft issue functions.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between a88a39f and 883f538.

📒 Files selected for processing (1)
  • web/core/components/workspace/sidebar/quick-actions.tsx (1 hunks)
🔇 Additional comments (1)
web/core/components/workspace/sidebar/quick-actions.tsx (1)

76-96: LGTM! Successfully improves issue creation UX

The conversion from div to button element successfully achieves the PR's objective of improving the issue creation interaction. The implementation:

  • Enhances accessibility through semantic HTML
  • Provides proper keyboard navigation
  • Maintains consistent styling with the design

Comment on lines 90 to 91
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
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

Remove unused mouse event handlers

These handlers appear to be related to the removed draft feature and are no longer needed.

-  onMouseEnter={handleMouseEnter}
-  onMouseLeave={handleMouseLeave}

Also remove the related handleMouseEnter, handleMouseLeave functions and timeoutRef.

📝 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
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}

Comment on lines +76 to +96
<button
type="button"
className={cn(
"relative flex-grow flex items-center justify-between gap-1 rounded h-8 hover:bg-custom-sidebar-background-90",
"relative flex flex-shrink-0 flex-grow items-center gap-2 h-8 text-custom-sidebar-text-300 rounded outline-none hover:bg-custom-sidebar-background-90",
{
"size-8 aspect-square": isSidebarCollapsed,
"justify-center size-8 aspect-square": isSidebarCollapsed,
"cursor-not-allowed opacity-50 ": disabled,
"px-3 border-[0.5px] border-custom-sidebar-border-300": !isSidebarCollapsed,
}
)}
onClick={() => {
setTrackElement("APP_SIDEBAR_QUICK_ACTIONS");
toggleCreateIssueModal(true);
}}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
disabled={disabled}
>
<button
type="button"
className={cn(
"relative flex flex-shrink-0 flex-grow items-center gap-2 text-custom-sidebar-text-300 rounded outline-none",
{
"justify-center": isSidebarCollapsed,
"cursor-not-allowed opacity-50": disabled,
}
)}
onClick={() => {
setTrackElement("APP_SIDEBAR_QUICK_ACTIONS");
toggleCreateIssueModal(true);
}}
disabled={disabled}
>
<PenSquare className="size-4" />
{!isSidebarCollapsed && <span className="text-sm font-medium">New issue</span>}
</button>
{/* {!disabled && workspaceDraftIssue && (
<>
{!isSidebarCollapsed && (
<button type="button" className="grid place-items-center">
<ChevronUp
className={cn("size-4 transform !text-custom-sidebar-text-300 transition-transform duration-300", {
"rotate-180": isDraftButtonOpen,
})}
/>
</button>
)}
{isDraftButtonOpen && (
<div className="absolute mt-0 h-10 w-[220px] pt-2 z-[16] top-8 left-0">
<div className="h-full w-full">
<button
onClick={() => setIsDraftIssueModalOpen(true)}
className="flex w-full flex-shrink-0 items-center rounded border-[0.5px] border-custom-border-300 bg-custom-background-100 px-3 py-[10px] text-sm text-custom-text-300 shadow"
>
<PenSquare size={16} className="mr-2 !text-lg !leading-4 text-custom-sidebar-text-300" />
Last drafted issue
</button>
</div>
</div>
)}
</>
)} */}
</div>
<PenSquare className="size-4" />
{!isSidebarCollapsed && <span className="text-sm font-medium">New issue</span>}
</button>
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

Enhance accessibility with ARIA attributes and tooltip

The conversion to a semantic button element is great for accessibility. Consider these additional improvements:

 <button
   type="button"
+  aria-label={isSidebarCollapsed ? "New issue" : undefined}
+  title={disabled ? "You need to join a project or have proper permissions to create issues" : "Create new issue"}
   className={cn(
     "relative flex flex-shrink-0 flex-grow items-center gap-2 h-8 text-custom-sidebar-text-300 rounded outline-none hover:bg-custom-sidebar-background-90",
     {
📝 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
<button
type="button"
className={cn(
"relative flex-grow flex items-center justify-between gap-1 rounded h-8 hover:bg-custom-sidebar-background-90",
"relative flex flex-shrink-0 flex-grow items-center gap-2 h-8 text-custom-sidebar-text-300 rounded outline-none hover:bg-custom-sidebar-background-90",
{
"size-8 aspect-square": isSidebarCollapsed,
"justify-center size-8 aspect-square": isSidebarCollapsed,
"cursor-not-allowed opacity-50 ": disabled,
"px-3 border-[0.5px] border-custom-sidebar-border-300": !isSidebarCollapsed,
}
)}
onClick={() => {
setTrackElement("APP_SIDEBAR_QUICK_ACTIONS");
toggleCreateIssueModal(true);
}}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
disabled={disabled}
>
<button
type="button"
className={cn(
"relative flex flex-shrink-0 flex-grow items-center gap-2 text-custom-sidebar-text-300 rounded outline-none",
{
"justify-center": isSidebarCollapsed,
"cursor-not-allowed opacity-50": disabled,
}
)}
onClick={() => {
setTrackElement("APP_SIDEBAR_QUICK_ACTIONS");
toggleCreateIssueModal(true);
}}
disabled={disabled}
>
<PenSquare className="size-4" />
{!isSidebarCollapsed && <span className="text-sm font-medium">New issue</span>}
</button>
{/* {!disabled && workspaceDraftIssue && (
<>
{!isSidebarCollapsed && (
<button type="button" className="grid place-items-center">
<ChevronUp
className={cn("size-4 transform !text-custom-sidebar-text-300 transition-transform duration-300", {
"rotate-180": isDraftButtonOpen,
})}
/>
</button>
)}
{isDraftButtonOpen && (
<div className="absolute mt-0 h-10 w-[220px] pt-2 z-[16] top-8 left-0">
<div className="h-full w-full">
<button
onClick={() => setIsDraftIssueModalOpen(true)}
className="flex w-full flex-shrink-0 items-center rounded border-[0.5px] border-custom-border-300 bg-custom-background-100 px-3 py-[10px] text-sm text-custom-text-300 shadow"
>
<PenSquare size={16} className="mr-2 !text-lg !leading-4 text-custom-sidebar-text-300" />
Last drafted issue
</button>
</div>
</div>
)}
</>
)} */}
</div>
<PenSquare className="size-4" />
{!isSidebarCollapsed && <span className="text-sm font-medium">New issue</span>}
</button>
<button
type="button"
aria-label={isSidebarCollapsed ? "New issue" : undefined}
title={disabled ? "You need to join a project or have proper permissions to create issues" : "Create new issue"}
className={cn(
"relative flex flex-shrink-0 flex-grow items-center gap-2 h-8 text-custom-sidebar-text-300 rounded outline-none hover:bg-custom-sidebar-background-90",
{
"justify-center size-8 aspect-square": isSidebarCollapsed,
"cursor-not-allowed opacity-50 ": disabled,
"px-3 border-[0.5px] border-custom-sidebar-border-300": !isSidebarCollapsed,
}
)}
onClick={() => {
setTrackElement("APP_SIDEBAR_QUICK_ACTIONS");
toggleCreateIssueModal(true);
}}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
disabled={disabled}
>
<PenSquare className="size-4" />
{!isSidebarCollapsed && <span className="text-sm font-medium">New issue</span>}
</button>

@pushya22 pushya22 merged commit 8829575 into preview Oct 29, 2024
@pushya22 pushya22 deleted the chore-app-sidebar-button-improvement branch October 29, 2024 08:12
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.

3 participants