Skip to content

Conversation

@anmolsinghbhatia
Copy link
Collaborator

@anmolsinghbhatia anmolsinghbhatia commented Nov 11, 2024

Changes:

This PR includes fix for create issue modal parent select ui.

Reference:

[WEB-2283]

Media:

Before After
before after

Summary by CodeRabbit

  • New Features

    • Improved layout for parent issue selection in the inbox and issue modal components.
  • Bug Fixes

    • Enhanced button styling for consistency in height and padding across components.
  • Documentation

    • No changes made.
  • Refactor

    • Restructured rendering logic for better organization and styling consistency.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 11, 2024

Walkthrough

The changes in this pull request involve modifications to the InboxIssueProperties and IssueDefaultProperties components, primarily focusing on layout and styling enhancements. The setIsOpen prop in IssueLabelSelect has been updated with an empty arrow function, while the structure of parent issue selection has been refactored to use <div> elements for improved styling. Button elements have been updated to ensure consistent height and padding, and the CustomMenu component has been adjusted to occupy full height. Overall, these changes aim to enhance the visual alignment without altering core functionality.

Changes

File Path Change Summary
web/core/components/inbox/modals/create-modal/issue-properties.tsx Updated setIsOpen prop to an empty arrow function, replaced fragment with <div>, modified button class for height consistency, and added class names to CustomMenu.
web/core/components/issues/issue-modal/components/default-properties.tsx Refactored parent issue selection rendering into a <div>, updated button classes for height and padding, and adjusted CustomMenu class names for full height.

Possibly related PRs

Suggested labels

🧹chore, 🌟enhancement

Suggested reviewers

  • sriramveeraghanta
  • SatishGandham

🐰 In the garden, changes bloom,
A modal's layout finds more room.
With buttons tall and menus wide,
Our issues now take greater pride!
So hop along, let's celebrate,
For every tweak makes things first-rate! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b5cf20b and e20d2a3.

📒 Files selected for processing (1)
  • web/core/components/inbox/modals/create-modal/issue-properties.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/core/components/inbox/modals/create-modal/issue-properties.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 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 November 11, 2024 09:24
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)
web/core/components/issues/issue-modal/components/default-properties.tsx (2)

265-320: LGTM! The parent issue selection UI improvements enhance consistency and usability.

The changes effectively address the UI issues by:

  • Maintaining consistent height (h-7) across all form elements
  • Providing clear visual feedback with hover states
  • Using semantic button elements with proper type attributes
  • Preserving functionality while improving the visual structure

Consider adding aria-label to improve accessibility:

  <button
    type="button"
+   aria-label="Add parent issue"
    className="flex cursor-pointer items-center justify-between gap-1 h-full rounded border-[0.5px] border-custom-border-300 px-2 py-0.5 text-xs hover:bg-custom-background-80"
    onClick={() => setParentIssueListModalOpen(true)}
  >

267-309: Enhance CustomMenu accessibility for keyboard users.

While the CustomMenu implementation is solid, consider these accessibility improvements:

  <CustomMenu
    customButton={
      <button
        type="button"
+       aria-label={`Current parent issue: ${selectedParentIssue?.project__identifier}-${selectedParentIssue?.sequence_id}`}
+       aria-haspopup="menu"
        className="flex cursor-pointer items-center justify-between gap-1 h-full rounded border-[0.5px] border-custom-border-300 px-2 py-0.5 text-xs hover:bg-custom-background-80"
      >
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 13083a7 and b5cf20b.

📒 Files selected for processing (2)
  • web/core/components/inbox/modals/create-modal/issue-properties.tsx (5 hunks)
  • web/core/components/issues/issue-modal/components/default-properties.tsx (1 hunks)
🔇 Additional comments (2)
web/core/components/inbox/modals/create-modal/issue-properties.tsx (2)

Line range hint 174-231: LGTM! UI improvements enhance visual consistency.

The changes effectively improve the parent issue selection UI by:

  • Maintaining consistent height with other form elements
  • Ensuring proper button padding and alignment
  • Utilizing full height in the CustomMenu component

94-94: Verify the impact of ignoring setIsOpen state management.

The empty arrow function () => {} for setIsOpen suggests that we're ignoring the modal's open state management. While this might be intentional if the state is managed internally, please verify that this doesn't break any functionality or accessibility features.

✅ Verification successful

Empty setIsOpen function is acceptable in this context

After analyzing the codebase, the empty arrow function () => {} for setIsOpen in IssueLabelSelect is acceptable because:

  1. The IssueLabelSelect component is used in two different contexts:

    • In issue-modal where it requires active state management (setIsOpen={setLabelModal})
    • In create-modal where state management is not needed (our case with setIsOpen={() => {}})
  2. Looking at the component definition in web/core/components/issues/select/label.tsx, setIsOpen is only used for handling the "Add new label" action, which is an optional feature not required in the create-modal context.

The implementation is consistent with React patterns where optional state management can be handled with no-op functions when the feature is not needed in a particular context.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other usages of IssueLabelSelect to verify if setIsOpen is used meaningfully elsewhere
ast-grep --pattern 'IssueLabelSelect $$$setIsOpen={$_}$$$'

Length of output: 60


Script:

#!/bin/bash
# Let's first find the IssueLabelSelect component definition
ast-grep --pattern 'export $_ function IssueLabelSelect' -l

# Also search for any file containing IssueLabelSelect
rg "IssueLabelSelect" --type typescript --type tsx -C 2

Length of output: 258


Script:

#!/bin/bash
# Search for IssueLabelSelect component definition and usage
rg "IssueLabelSelect" -t ts -t tsx -C 3

# Find the file that might contain the component
fd "IssueLabelSelect" --extension tsx --extension ts

Length of output: 120


Script:

#!/bin/bash
# Search for IssueLabelSelect using basic grep with context
grep -r "IssueLabelSelect" . --include="*.tsx" --include="*.ts" -C 3

# Also look for any modal-related components that might use setIsOpen
grep -r "setIsOpen" . --include="*.tsx" --include="*.ts" -C 2

Length of output: 56597

Comment on lines +293 to +307
<Controller
control={control}
name="parent_id"
render={({ field: { onChange } }) => (
<CustomMenu.MenuItem
className="!p-1"
onClick={() => {
onChange(null);
handleFormChange();
}}
>
Remove parent issue
</CustomMenu.MenuItem>
)}
/>
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

Consider consolidating parent_id Controllers.

There are two separate Controllers for the parent_id field. Consider refactoring to use a single Controller to improve maintainability:

- <Controller
-   control={control}
-   name="parent_id"
-   render={({ field: { onChange } }) => (
-     <CustomMenu.MenuItem
-       className="!p-1"
-       onClick={() => {
-         onChange(null);
-         handleFormChange();
-       }}
-     >
-       Remove parent issue
-     </CustomMenu.MenuItem>
-   )}
- />

  <Controller
    control={control}
    name="parent_id"
    render={({ field: { onChange } }) => (
+     <>
+       {parentId && (
+         <CustomMenu.MenuItem
+           className="!p-1"
+           onClick={() => {
+             onChange(null);
+             handleFormChange();
+           }}
+         >
+           Remove parent issue
+         </CustomMenu.MenuItem>
+       )}
        <ParentIssuesListModal
          isOpen={parentIssueListModalOpen}
          handleClose={() => setParentIssueListModalOpen(false)}
          onChange={(issue) => {
            onChange(issue.id);
            handleFormChange();
            setSelectedParentIssue(issue);
          }}
          projectId={projectId ?? undefined}
          issueId={isDraft ? undefined : id}
        />
+     </>
    )}
  />

Also applies to: 321-341

@pushya22 pushya22 merged commit c7c729d into preview Nov 11, 2024
@pushya22 pushya22 deleted the fix-create-issue-modal-parent-select-ui branch November 11, 2024 10:41
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.

4 participants