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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ function Action(props: ActionPropsType) {

return tooltip ? (
<Tooltip title={tooltip}>
<span>{content}</span>{" "}
{/* Use <span> to wrap the child to avoid DOM issues */}
<span>{content}</span>
</Tooltip>
) : (
content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export default function TableView(props: ViewPropsType) {
selectedColumns.has(columnIndex);

const tooltip = tooltipMap[coordinate]; // Check if there's a tooltip for the cell

const content = formatCellValue(item[key], props);
const cell = (
<TableCell
key={key}
Expand All @@ -197,11 +197,9 @@ export default function TableView(props: ViewPropsType) {
>
{tooltip ? (
<Tooltip title={tooltip} arrow>
<span>{formatCellValue(item[key], props)}</span> {/* Wrap content with Tooltip */}
<span> {content} </span>
</Tooltip>
) : (
formatCellValue(item[key], props) // No Tooltip for cells without tooltips
)}
) : (content)}
Comment on lines +200 to +202
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.

</TableCell>
);

Expand Down
Loading