Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix for TableView tooltip #5158

Merged
merged 2 commits into from
Nov 20, 2024
Merged

Bug fix for TableView tooltip #5158

merged 2 commits into from
Nov 20, 2024

Conversation

minhtuev
Copy link
Contributor

@minhtuev minhtuev commented Nov 20, 2024

What changes are proposed in this pull request?

In teams, Tooltip cannot handle multiple children at once and thus causing error

How is this patch tested? If it is not, please explain why.

  • Tested locally (Cam)

Release Notes

Is this a user-facing change that should be mentioned in the release notes?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release
    notes for FiftyOne users.

(Details in 1-2 sentences. You can just refer to another PR with a description
if this PR is part of a larger change.)

What areas of FiftyOne does this PR affect?

  • App: FiftyOne application changes
  • Build: Build and test infrastructure changes
  • Core: Core fiftyone Python library changes
  • Documentation: FiftyOne documentation changes
  • Other

Summary by CodeRabbit

  • Improvements

    • Enhanced readability of the TableView component by simplifying cell content rendering and tooltip management.
  • Refactor

    • Removed unnecessary comments in the ActionsMenu component to streamline the code while maintaining existing functionality.

Copy link
Contributor

coderabbitai bot commented Nov 20, 2024

Walkthrough

The changes in this pull request involve modifications to the ActionsMenu and TableView components. In ActionsMenu.tsx, a comment was removed from the Action function, but the component's functionality and structure remain unchanged. In TableView.tsx, the logic for rendering cell content was updated to improve readability, utilizing a new variable for formatted content, while also adjusting tooltip rendering. No alterations were made to the declarations of exported or public entities in either component.

Changes

File Path Change Summary
app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx Removed a comment in the Action function; functionality and structure remain unchanged.
app/packages/core/src/plugins/SchemaIO/components/TableView.tsx Updated cell content rendering to use a new content variable; adjusted tooltip rendering logic for clarity.

Possibly related PRs

  • TableView enhancements #4809: The changes in the TableView component regarding the handling of actions and rendering logic are related to the main PR's modifications to the ActionsMenu component, as both involve the management of actions within the table context.
  • fix TableView for backward compatibility #4953: This PR enhances the TableView component's functionality, particularly in relation to selection management and value formatting, which aligns with the main PR's focus on the ActionsMenu and its interaction with the TableView.
  • fix non-editable views state issue and conditional row actions for TableView #4969: The modifications to the TableView component's handling of row actions and selection states are relevant to the main PR, which discusses the ActionsMenu and its integration within the table.
  • Update TableView with multi inline actions #5118: The addition of the max_inline_actions property in the TableView component directly relates to the main PR's focus on the ActionsMenu, as it allows for customization of the number of inline actions displayed.
  • Tooltip support for TableView actions #5142: The introduction of tooltip support for actions in the TableView is directly relevant to the main PR, which discusses changes to the ActionsMenu component that also involve tooltip functionality.
  • Add support for cell tooltip in TableView #5152: The addition of tooltip support for cells in the TableView complements the main PR's focus on enhancing the ActionsMenu with tooltip capabilities, indicating a broader effort to improve user interface interactions across components.

Suggested labels

app

Suggested reviewers

  • ritch

🐰 In the meadow where we play,
Changes hop in bright array.
Comments gone, but all's the same,
Tooltips dance, and content's fame.
Actions menu, clear and bright,
Code is tidy, what a sight! 🌼


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.

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

🧹 Outside diff range and nitpick comments (1)
app/packages/core/src/plugins/SchemaIO/components/TableView.tsx (1)

Line range hint 186-202: Consider performance and type safety improvements

The tooltip implementation could benefit from the following enhancements:

  1. Memoize tooltip components to prevent unnecessary re-renders
  2. Add proper TypeScript types for tooltip data

Consider these improvements:

// Add at the top of the file
interface TooltipData {
  value: string;
  row: number;
  column: number;
}

// Memoize the tooltip cell content
const TooltipContent = React.memo(({ content, tooltip }: { content: React.ReactNode; tooltip: string }) => (
  <Tooltip title={tooltip} arrow aria-label={`Additional information: ${tooltip}`}>
    <span>{content}</span>
  </Tooltip>
));

Then update the cell rendering:

                      {tooltip ? (
-                         <Tooltip title={tooltip} arrow>
-                           <span> {content} </span>
-                         </Tooltip>
+                         <TooltipContent content={content} tooltip={tooltip} />
                      ) : (content)}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ac2b63a and d2f2a7e.

📒 Files selected for processing (2)
  • app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx (1 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/TableView.tsx (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx
🧰 Additional context used
📓 Path-based instructions (1)
app/packages/core/src/plugins/SchemaIO/components/TableView.tsx (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

🔇 Additional comments (1)
app/packages/core/src/plugins/SchemaIO/components/TableView.tsx (1)

186-186: LGTM! Good refactoring for readability

The introduction of the content variable improves code readability by avoiding repeated formatCellValue calls and follows React best practices by computing values before JSX.

Comment on lines +200 to +202
<span> {content} </span>
</Tooltip>
) : (
formatCellValue(item[key], props) // No Tooltip for cells without tooltips
)}
) : (content)}
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

Improve tooltip implementation

The current implementation has several issues:

  1. Extra whitespace in <span> {content} </span> will be rendered as padding
  2. The span wrapper might be unnecessary
  3. Missing accessibility attributes for better screen reader support

Consider applying these improvements:

-              <span> {content} </span>
+              <span>{content}</span>

Also, enhance accessibility by adding aria attributes to the Tooltip:

-          <Tooltip title={tooltip} arrow>
+          <Tooltip 
+            title={tooltip}
+            arrow
+            aria-label={`Additional information: ${tooltip}`}
+          >

Committable suggestion skipped: line range outside the PR's diff.

Copy link

@jleven jleven left a comment

Choose a reason for hiding this comment

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

LGTM

@minhtuev minhtuev enabled auto-merge (squash) November 20, 2024 02:47
@minhtuev minhtuev merged commit 7785ecd into develop Nov 20, 2024
12 checks passed
@minhtuev minhtuev deleted the bug/tableview-content branch November 20, 2024 02:54
minhtuev added a commit that referenced this pull request Nov 20, 2024
* Single child for tooltip

---------

Co-authored-by: minhtuevo <[email protected]>
minhtuev added a commit that referenced this pull request Nov 20, 2024
* Single child for tooltip

---------

Co-authored-by: minhtuevo <[email protected]>
CamronStaley pushed a commit that referenced this pull request Nov 20, 2024
* Single child for tooltip

---------

Co-authored-by: minhtuevo <[email protected]>
@coderabbitai coderabbitai bot mentioned this pull request Jan 7, 2025
6 tasks
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.

4 participants