[WEB-2725] chore: app sidebar add issue button improvement#5921
[WEB-2725] chore: app sidebar add issue button improvement#5921
Conversation
WalkthroughThe changes in this pull request focus on the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
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 classesThe 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 codeSeveral state variables and related code for the removed draft functionality can be cleaned up:
- Remove unused states:
- const [isDraftIssueModalOpen, setIsDraftIssueModalOpen] = useState(false); - const [isDraftButtonOpen, setIsDraftButtonOpen] = useState(false); - const timeoutRef = useRef<any>();
Remove the
CreateUpdateIssueModalcomponent instance and related code since it's only used for drafts.Remove the
useLocalStoragehook usage and related draft issue functions.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 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 UXThe 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
| onMouseEnter={handleMouseEnter} | ||
| onMouseLeave={handleMouseLeave} |
There was a problem hiding this comment.
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.
| onMouseEnter={handleMouseEnter} | |
| onMouseLeave={handleMouseLeave} |
| <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> |
There was a problem hiding this comment.
🛠️ 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.
| <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> |
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
divto a semantically correctbutton.Bug Fixes
Refactor