Skip to content

Comments

[WEB-1936] fix: flicker issue in issues list layout#5412

Merged
SatishGandham merged 4 commits intopreviewfrom
fix-issue-flickering
Aug 26, 2024
Merged

[WEB-1936] fix: flicker issue in issues list layout#5412
SatishGandham merged 4 commits intopreviewfrom
fix-issue-flickering

Conversation

@gakshita
Copy link
Collaborator

@gakshita gakshita commented Aug 22, 2024

Summary
Flicker issue on issue creation and sub issue view fixed

[WEB-1936]

Summary by CodeRabbit

  • New Features

    • Introduced defaultValue prop for the RenderIfVisible component, allowing initial visibility state configuration.
    • Added shouldRenderByDefault prop to the IssueBlockRoot component, enhancing conditional rendering capabilities.
    • Implemented conditional rendering in IssueBlocksList to highlight issues created within the last 30 seconds.
    • Added a new function to determine if an issue is considered "new" based on its creation date.
  • Improvements

    • Enhanced configurability and responsiveness of components based on props, leading to a more dynamic user interface.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 22, 2024

Walkthrough

The recent changes introduce optional properties to the RenderIfVisible and IssueBlockRoot components, enhancing their flexibility for visibility control. The IssueBlocksList component has been updated to conditionally render IssueBlockRoot based on issue creation timestamps. Additionally, a new utility function isIssueNew has been added to determine if an issue is newly created, improving the responsiveness of the user interface to dynamic data.

Changes

Files & Directories Change Summary
web/core/components/core/render-if-visible-HOC.tsx Added defaultValue prop to RenderIfVisible for initial visibility state; modified state initialization for shouldVisible.
web/core/components/issues/issue-layouts/list/block-root.tsx Introduced shouldRenderByDefault prop to IssueBlockRoot, affecting its rendering logic.
web/core/components/issues/issue-layouts/list/blocks-list.tsx Updated IssueBlocksList to conditionally render IssueBlockRoot based on issue creation timestamps; added shouldRenderByDefault prop to manage rendering.
web/core/components/issues/issue-layouts/utils.tsx Added isIssueNew function to determine if an issue is newly created based on its timestamp.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant IssueBlocksList
    participant IssueBlockRoot

    User->>IssueBlocksList: Request to display issues
    IssueBlocksList->>IssueBlockRoot: Check creation timestamp
    alt Created within last 30 seconds
        IssueBlocksList->>IssueBlockRoot: Render with shouldRenderByDefault = true
    else Created more than 30 seconds ago
        IssueBlocksList->>IssueBlockRoot: Render with shouldRenderByDefault = false
    end
Loading

Poem

🌟 In the garden where ideas bloom,
A rabbit hops to chase away gloom.
With props that dance and logic that sings,
Rendering joy, oh, what delight it brings!
From issues new to those of old,
A tale of flexibility, sweetly told! 🐇✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

Outside diff range, codebase verification and nitpick comments (1)
web/core/components/issues/issue-layouts/list/blocks-list.tsx (1)

45-46: Consider renaming shouldRenderByDefault for clarity.

The variable name shouldRenderByDefault could be more descriptive to indicate its purpose, such as isRecentlyCreated.

- const shouldRenderByDefault =
+ const isRecentlyCreated =
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 460003c and 954c7a2.

Files selected for processing (3)
  • web/core/components/core/render-if-visible-HOC.tsx (2 hunks)
  • web/core/components/issues/issue-layouts/list/block-root.tsx (4 hunks)
  • web/core/components/issues/issue-layouts/list/blocks-list.tsx (1 hunks)
Additional comments not posted (3)
web/core/components/issues/issue-layouts/list/blocks-list.tsx (1)

48-70: Conditional rendering logic is well-implemented.

The conditional rendering of IssueBlockRoot based on the issue's creation time is a good enhancement for highlighting recently created issues.

web/core/components/core/render-if-visible-HOC.tsx (1)

Line range hint 13-28: The addition of defaultValue is a valuable enhancement.

Using defaultValue to initialize the shouldVisible state enhances the component's flexibility and usability.

web/core/components/issues/issue-layouts/list/block-root.tsx (1)

Line range hint 39-171: The addition of shouldRenderByDefault enhances configurability.

The shouldRenderByDefault prop allows for more nuanced rendering based on the component's state, improving the component's flexibility.

@gakshita gakshita requested a review from rahulramesha August 23, 2024 06:56
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 954c7a2 and 03dc171.

Files selected for processing (2)
  • web/core/components/issues/issue-layouts/list/blocks-list.tsx (2 hunks)
  • web/core/components/issues/issue-layouts/utils.tsx (1 hunks)
Additional comments not posted (1)
web/core/components/issues/issue-layouts/utils.tsx (1)

616-621: Verify date handling in isIssueNew function.

The logic for determining if an issue is new is correct, but consider handling edge cases such as invalid dates or time zone differences. Ensure that issue.created_at is always a valid date string.

Run the following script to check for invalid created_at values:

Comment on lines 44 to 67
issueIds.map(
(issueId: string, index: number) =>
issuesMap[issueId].created_at && (
<IssueBlockRoot
key={issueId}
issueIds={issueIds}
issueId={issueId}
issuesMap={issuesMap}
updateIssue={updateIssue}
quickActions={quickActions}
canEditProperties={canEditProperties}
displayProperties={displayProperties}
nestingLevel={0}
spacingLeft={0}
containerRef={containerRef}
selectionHelpers={selectionHelpers}
groupId={groupId}
isLastChild={index === issueIds.length - 1}
isDragAllowed={isDragAllowed}
canDropOverIssue={canDropOverIssue}
shouldRenderByDefault={isIssueNew(issuesMap[issueId])}
/>
)
)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider extracting the rendering logic into a separate function.

The rendering logic for IssueBlockRoot could be moved to a separate function to enhance reusability and readability, as previously suggested by another reviewer.

+const renderIssueBlock = (issueId, index) => (
+  issuesMap[issueId].created_at && (
+    <IssueBlockRoot
+      key={issueId}
+      issueIds={issueIds}
+      issueId={issueId}
+      issuesMap={issuesMap}
+      updateIssue={updateIssue}
+      quickActions={quickActions}
+      canEditProperties={canEditProperties}
+      displayProperties={displayProperties}
+      nestingLevel={0}
+      spacingLeft={0}
+      containerRef={containerRef}
+      selectionHelpers={selectionHelpers}
+      groupId={groupId}
+      isLastChild={index === issueIds.length - 1}
+      isDragAllowed={isDragAllowed}
+      canDropOverIssue={canDropOverIssue}
+      shouldRenderByDefault={isIssueNew(issuesMap[issueId])}
+    />
+  )
+);

return (
  <div className="relative h-full w-full">
    {issueIds && issueIds.length > 0 && issueIds.map(renderIssueBlock)}
  </div>
);
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
issueIds.map(
(issueId: string, index: number) =>
issuesMap[issueId].created_at && (
<IssueBlockRoot
key={issueId}
issueIds={issueIds}
issueId={issueId}
issuesMap={issuesMap}
updateIssue={updateIssue}
quickActions={quickActions}
canEditProperties={canEditProperties}
displayProperties={displayProperties}
nestingLevel={0}
spacingLeft={0}
containerRef={containerRef}
selectionHelpers={selectionHelpers}
groupId={groupId}
isLastChild={index === issueIds.length - 1}
isDragAllowed={isDragAllowed}
canDropOverIssue={canDropOverIssue}
shouldRenderByDefault={isIssueNew(issuesMap[issueId])}
/>
)
)}
const renderIssueBlock = (issueId, index) => (
issuesMap[issueId].created_at && (
<IssueBlockRoot
key={issueId}
issueIds={issueIds}
issueId={issueId}
issuesMap={issuesMap}
updateIssue={updateIssue}
quickActions={quickActions}
canEditProperties={canEditProperties}
displayProperties={displayProperties}
nestingLevel={0}
spacingLeft={0}
containerRef={containerRef}
selectionHelpers={selectionHelpers}
groupId={groupId}
isLastChild={index === issueIds.length - 1}
isDragAllowed={isDragAllowed}
canDropOverIssue={canDropOverIssue}
shouldRenderByDefault={isIssueNew(issuesMap[issueId])}
/>
)
);
return (
<div className="relative h-full w-full">
{issueIds && issueIds.length > 0 && issueIds.map(renderIssueBlock)}
</div>
);

Copy link
Contributor

@rahulramesha rahulramesha left a comment

Choose a reason for hiding this comment

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

@gakshita can you please make the small change requested. Apologies as i didn't notice it the first time

))}
issueIds.map(
(issueId: string, index: number) =>
issuesMap[issueId].created_at && (
Copy link
Contributor

Choose a reason for hiding this comment

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

@gakshita One more small change, can you please reference the issue object only inside the component. Because referencing here might rerender the entire list, when one of the issue object changes

isLastChild={index === issueIds.length - 1}
isDragAllowed={isDragAllowed}
canDropOverIssue={canDropOverIssue}
shouldRenderByDefault={isIssueNew(issuesMap[issueId])}
Copy link
Contributor

Choose a reason for hiding this comment

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

Here as well, can you just make sure to use the logic from within the IssueBlockRoot instead.

@gakshita gakshita requested a review from rahulramesha August 26, 2024 08:22
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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 03dc171 and 75f9808.

Files selected for processing (1)
  • web/core/components/issues/issue-layouts/list/block-root.tsx (6 hunks)
Files skipped from review as they are similar to previous changes (1)
  • web/core/components/issues/issue-layouts/list/block-root.tsx

Copy link
Contributor

@rahulramesha rahulramesha left a comment

Choose a reason for hiding this comment

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

@gakshita had one minor change, please let me know once done

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 75f9808 and eeb1ea1.

Files selected for processing (1)
  • web/core/components/issues/issue-layouts/list/block-root.tsx (6 hunks)
Files skipped from review as they are similar to previous changes (1)
  • web/core/components/issues/issue-layouts/list/block-root.tsx

@SatishGandham SatishGandham merged commit 803992c into preview Aug 26, 2024
@SatishGandham SatishGandham deleted the fix-issue-flickering branch August 26, 2024 11:26
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.

3 participants