Skip to content

Comments

[WEB-2710] fix: issue widget modal rendering#5896

Merged
pushya22 merged 1 commit intopreviewfrom
fix-issue-widget-modal-rendering
Oct 23, 2024
Merged

[WEB-2710] fix: issue widget modal rendering#5896
pushya22 merged 1 commit intopreviewfrom
fix-issue-widget-modal-rendering

Conversation

@anmolsinghbhatia
Copy link
Collaborator

@anmolsinghbhatia anmolsinghbhatia commented Oct 23, 2024

Changes:

This PR resolves a bug related to the widget modal rendering. The issue occurred when a user opened a sub-issue in peek overview mode from the detail page and then tried to open a widget modal. This action triggered the widget modal for both the peek overview and the issue detail page, causing two modals to open simultaneously.

To fix this, I have added a render condition for the issue detail widget modal. Now, when peek overview mode is active, the issue detail widget modal will not render, preventing two modals from opening at the same time.

Reference:

[WEB-2710]

Summary by CodeRabbit

  • New Features

    • Introduced a new optional property renderWidgetModals for conditional rendering of modals in the IssueDetailWidgets component.
    • Added "peek mode" functionality to the IssueMainContent component, allowing for dynamic display of widget modals based on the active state.
  • Bug Fixes

    • Improved alert management during submission processes in the IssueMainContent component.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 23, 2024

Walkthrough

The changes introduce a new optional property, renderWidgetModals, to the IssueDetailWidgets component, allowing conditional rendering of its associated modal component. This property defaults to true. In the IssueMainContent component, the rendering of renderWidgetModals is now dependent on a new state variable, isPeekModeActive, which is derived from the peekIssue variable. These modifications enhance the flexibility of rendering widget modals based on the active state of the issue being viewed.

Changes

File Path Change Summary
web/core/components/issues/issue-detail-widgets/root.tsx Added optional property renderWidgetModals to Props type, updating rendering logic accordingly.
web/core/components/issues/issue-detail/main-content.tsx Introduced peekIssue and isPeekModeActive variables; updated renderWidgetModals prop based on isPeekModeActive.

Possibly related PRs

Suggested labels

🌟improvement

Suggested reviewers

  • sriramveeraghanta
  • SatishGandham

🐇 In the meadow, where ideas bloom,
A widget's magic clears the gloom.
With peek mode's charm, we now can see,
Modals dancing, wild and free!
So let us hop and celebrate,
For changes made, we elevate! 🌼✨


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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6df9809 and 7c66f57.

📒 Files selected for processing (2)
  • web/core/components/issues/issue-detail-widgets/root.tsx (2 hunks)
  • web/core/components/issues/issue-detail/main-content.tsx (3 hunks)
🧰 Additional context used
🔇 Additional comments (3)
web/core/components/issues/issue-detail-widgets/root.tsx (1)

15-15: LGTM! Clean type definition.

The optional boolean prop is well-defined and follows TypeScript best practices.

web/core/components/issues/issue-detail/main-content.tsx (2)

43-43: LGTM: Clean hook usage

The addition of peekIssue from the useIssueDetail hook is clean and follows React patterns.


116-116: LGTM: Effectively prevents double modal rendering

The renderWidgetModals prop correctly prevents widget modal rendering during peek mode, addressing the original issue.

Let's verify that this is the only instance where widget modals are rendered:

✅ Verification successful

Let me try a different search strategy to verify the widget modal rendering implementation.

This will help us:

  1. Find all usages of IssueDetailWidgets component and its props
  2. Find any other widget modal related code that might be relevant

Verification complete: Widget modal rendering control is properly implemented

The search results confirm that the widget modal rendering is correctly controlled:

  • The renderWidgetModals prop is defined in IssueDetailWidgets component with a default value of true
  • The prop is properly used in the component to conditionally render IssueDetailWidgetModals using {renderWidgetModals && (...)}
  • The only place where this prop is explicitly set to prevent rendering is in the issue detail main content with !isPeekModeActive
  • No other instances of widget modal rendering were found that could cause double rendering
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other potential widget modal rendering locations
rg -l "IssueDetailWidgets.*renderWidgetModals" 

Length of output: 48


Script:

#!/bin/bash
# Search for IssueDetailWidgets component usage
rg "IssueDetailWidgets" -A 3

# Also search for any widget modal related code
rg -i "widgetmodal|widget.*modal" -A 2

Length of output: 4102


export const IssueDetailWidgets: FC<Props> = (props) => {
const { workspaceSlug, projectId, issueId, disabled } = props;
const { workspaceSlug, projectId, issueId, disabled, renderWidgetModals = true } = props;
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Component usage needs attention - renderWidgetModals prop is not being passed

The search results show that IssueDetailWidgets is being used in three locations:

  • web/core/components/issues/issue-detail/main-content.tsx
  • web/core/components/issues/peek-overview/view.tsx (two instances)

However, none of these usages are passing the renderWidgetModals prop, which could lead to unexpected behavior. While the prop has a default value of true, the peek overview component might benefit from explicitly setting this prop to false to prevent modal rendering in peek mode.

Locations needing attention:

  • web/core/components/issues/peek-overview/view.tsx: Both instances should consider setting renderWidgetModals={false}
  • web/core/components/issues/issue-detail/main-content.tsx: Should explicitly set renderWidgetModals={true} for clarity
🔗 Analysis chain

LGTM! Clean implementation of conditional rendering.

The implementation effectively solves the dual modal issue while maintaining backward compatibility through the default true value. The conditional rendering is clean and straightforward.

Let's verify that this component is properly used with the new prop in the parent components:

Also applies to: 36-38


Let me try a different approach to verify the usage of this component.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of IssueDetailWidgets with renderWidgetModals prop
# Expected: Should find usage in IssueMainContent where renderWidgetModals is set based on peek mode

# Search for IssueDetailWidgets usage
ast-grep --pattern 'IssueDetailWidgets $$$renderWidgetModals={$_}$$$'

Length of output: 71


Script:

#!/bin/bash
# Let's first find all files that import or use IssueDetailWidgets
rg "IssueDetailWidgets" -l

# Then let's see the actual usage context
rg "IssueDetailWidgets" -A 3 -B 3

Length of output: 3720

Comment on lines +57 to +58
const isPeekModeActive = Boolean(peekIssue);

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 memoizing the peek mode state

While the current implementation is correct, consider memoizing isPeekModeActive if peekIssue changes frequently to prevent unnecessary re-renders.

-  const isPeekModeActive = Boolean(peekIssue);
+  const isPeekModeActive = useMemo(() => Boolean(peekIssue), [peekIssue]);

Committable suggestion was skipped due to low confidence.

@pushya22 pushya22 merged commit c4421f5 into preview Oct 23, 2024
@pushya22 pushya22 deleted the fix-issue-widget-modal-rendering branch October 23, 2024 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛bug Something isn't working 🌐frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants