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

Tooltip support for TableView actions (#5142) #5145

Merged
merged 1 commit into from
Nov 19, 2024

Conversation

minhtuev
Copy link
Contributor

@minhtuev minhtuev commented Nov 19, 2024

  • Added tooltip to actions
  • Added tooltip to Python obj
  • Left align actions column and fix spacing

Summary by CodeRabbit

  • New Features
    • Introduced tooltips for actions in the ActionsMenu and TableView components to enhance user guidance.
  • Improvements
    • Adjusted layout of action items for better alignment and clarity in the ActionsMenu.
    • Enhanced row action handling in TableView for improved user interaction and clarity.
  • Bug Fixes
    • Updated click handling logic to ensure accurate response to user interactions across cells, rows, and columns.

* Added tooltip to actions
* Added tooltip to Python obj
* Left align actions column and fix spacing

---------

Co-authored-by: minhtuevo <[email protected]>
Co-authored-by: CamronStaley <[email protected]>
@minhtuev minhtuev marked this pull request as ready for review November 19, 2024 04:03
Copy link
Contributor

coderabbitai bot commented Nov 19, 2024

Walkthrough

The pull request introduces enhancements to the ActionsMenu and TableView components by integrating tooltip functionality for action items. In ActionsMenu.tsx, a new Tooltip component is utilized, and the Action function now accepts a tooltip prop. The alignment of action items is adjusted, and the rendering logic is refactored for modularity. In TableView.tsx, the header's text alignment is modified, and row action rendering logic is clarified. Additionally, the add_row_action method in TableView is updated to accept an optional tooltip parameter.

Changes

File Change Summary
app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx - Introduced Tooltip component.
- Updated Action function to include tooltip prop.
- Changed Stack alignment.
- Refactored rendering logic for actions.
app/packages/core/src/plugins/SchemaIO/components/TableView.tsx - Changed header TableCell text alignment from "right" to "left".
- Introduced currentRowHasActions variable.
- Updated handleCellClick for better event handling.
fiftyone/operators/types.py - Updated add_row_action method to include optional tooltip parameter.

Possibly related PRs

Suggested reviewers

  • ritch
  • imanjra

🐇 In the garden, changes bloom,
Tooltips sprout, dispelling gloom.
Actions now with hints to show,
Clarity in every flow.
A hop, a skip, a joyful cheer,
Enhancements made, the path is clear! 🌼


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 (3)
app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx (2)

111-115: Consider using styled component for tooltip wrapper

While using a span wrapper is necessary to avoid DOM nesting issues with Material-UI Tooltip, consider creating a styled component for better type safety and potential reuse.

Example implementation:

const TooltipWrapper = styled('span')({
  display: 'inline-block'
});

// Usage
<Tooltip title={tooltip}>
  <TooltipWrapper>{content}</TooltipWrapper>
</Tooltip>

138-138: Consider using optional property for tooltip

Instead of using string | null, consider making tooltip an optional property using ?: syntax for better TypeScript idioms.

Apply this diff:

-  tooltip: string | null;
+  tooltip?: string;
app/packages/core/src/plugins/SchemaIO/components/TableView.tsx (1)

144-146: Consider improving the responsive layout handling

While the left alignment is good, the current width calculation (${max_inline_actions * 5}%) might cause layout issues:

  1. On small screens, the actions column might become too narrow
  2. With many inline actions, the column could become disproportionately wide

Consider this more responsive approach:

-width={`${max_inline_actions * 5}%`}
+sx={{
+  ...headingCellBaseStyles,
+  textAlign: "left",
+  width: {
+    xs: "auto",
+    sm: `clamp(100px, ${max_inline_actions * 5}%, 200px)`,
+  }
+}}

This ensures:

  • A minimum width for usability
  • A maximum width to prevent layout disruption
  • Responsive behavior on different screen sizes
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between bba04b8 and a0e189a.

📒 Files selected for processing (3)
  • app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx (5 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/TableView.tsx (1 hunks)
  • fiftyone/operators/types.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.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.

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 (6)
app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx (3)

12-12: LGTM: Tooltip import is correctly placed

The Tooltip import from @mui/material is properly grouped with other Material-UI imports.


24-24: LGTM: Consistent layout alignment

The change to left-align actions (justifyContent="flex-start") improves visual consistency and matches common UI patterns.


77-78: Verify tooltip accessibility and implementation

Let's ensure proper tooltip implementation across the codebase.

Also applies to: 111-115

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

144-146: Verify tooltip implementation for actions

The PR objectives mention adding tooltip support for TableView actions, but the tooltip implementation is not visible in these changes.

Let's verify the tooltip implementation:

✅ Verification successful

Tooltip implementation is correctly in place

The tooltip support is properly implemented in the ActionsMenu component. The component accepts a tooltip prop in its action items (ActionPropsType) and renders it using MUI's Tooltip component. The TableView passes row actions to ActionsMenu, which can include tooltips through the row_actions configuration.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for tooltip-related code in the codebase

# Search for tooltip-related imports and usage
echo "Searching for tooltip-related code..."
rg -i "tooltip" --type ts --type tsx

# Check ActionsMenu component for tooltip implementation
echo "Checking ActionsMenu component..."
fd -e tsx -e ts "ActionsMenu" -x cat {}

Length of output: 3563


Script:

#!/bin/bash
# Check if the tooltip property is being passed to ActionsMenu in TableView
rg -A 5 -B 5 "ActionsMenu" app/packages/core/src/plugins/SchemaIO/components/TableView.tsx

# Check if there are any recent changes related to tooltip in the PR
git diff origin/main -- app/packages/core/src/plugins/SchemaIO/components/TableView.tsx | rg -i "tooltip"

Length of output: 1093


Script:

#!/bin/bash
# Check how row actions are constructed in TableView
rg -A 10 "getRowActions" app/packages/core/src/plugins/SchemaIO/components/TableView.tsx

# Check if tooltip is being passed in the row actions configuration
rg "tooltip.*actions" app/packages/core/src/plugins/SchemaIO/components/TableView.tsx

Length of output: 1544

fiftyone/operators/types.py (2)

1827-1827: LGTM! Clear documentation for the tooltip parameter.

The tooltip parameter is well-documented and follows the existing docstring style.


1863-1865: LGTM! Clean implementation of tooltip support.

The tooltip parameter is properly added to the method signature and correctly passed to the Action constructor. This change aligns with the PR objective of adding tooltip support for TableView actions.


return tooltip ? (
<Tooltip title={tooltip}>
<span>{content}</span>{" "}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove extra whitespace character

The extra space after the closing span tag (</span>{" "}) could cause unwanted layout spacing.

Apply this diff to fix the whitespace:

-      <span>{content}</span>{" "}
+      <span>{content}</span>
📝 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
<span>{content}</span>{" "}
<span>{content}</span>

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.

2 participants