-
Notifications
You must be signed in to change notification settings - Fork 605
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
fix panel rows not refreshing on action changes #5164
Conversation
WalkthroughThe pull request modifies the Changes
Possibly related PRs
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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 and nitpick comments (2)
app/packages/core/src/plugins/SchemaIO/components/TableView.tsx (2)
38-38
: Add TypeScript type annotation for tooltips propConsider adding a type annotation for the tooltips prop to improve type safety and documentation.
- tooltips = [], + tooltips: Array<{ value: string; row: number; column: number }> = [],
Line range hint
187-212
: Optimize cell rendering and tooltip implementationSeveral improvements can be made to enhance performance and readability:
- const tooltip = tooltipMap[coordinate]; - const content = formatCellValue(item[key], props); - const cell = ( - <TableCell - key={key} - sx={{ - background: isSelected - ? selectedCellColor - : "unset", - }} - onClick={() => { - handleClick(rowIndex, columnIndex); - }} - {...getComponentProps(props, "tableBodyCell")} - > - {tooltip ? ( - <Tooltip title={tooltip} arrow> - <span> {content} </span> - </Tooltip> - ) : ( - content - )} - </TableCell> - ); - - return cell; + return ( + <TableCell + key={key} + sx={{ + background: isSelected ? selectedCellColor : "unset", + }} + onClick={() => handleClick(rowIndex, columnIndex)} + {...getComponentProps(props, "tableBodyCell")} + > + {tooltipMap[coordinate] ? ( + <Tooltip title={tooltipMap[coordinate]} arrow> + <span>{formatCellValue(item[key], props)}</span> + </Tooltip> + ) : ( + formatCellValue(item[key], props) + )} + </TableCell> + );Changes:
- Removed unnecessary variable declarations
- Simplified background styling
- Removed extra spaces in tooltip content
- Directly used tooltipMap lookup
- Simplified the return statement
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
app/packages/core/src/plugins/SchemaIO/components/TableView.tsx
(4 hunks)
🧰 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)
50-69
: Dependency array update fixes the refresh issue
The addition of missing dependencies (row_actions
, handleClick
, panelId
, path
) to the useCallback
hook's dependency array resolves the panel rows not refreshing issue. This ensures the callback is properly updated when these dependencies change.
Let's verify there are no other callbacks missing dependencies:
✅ Verification successful
Let me analyze the useCallback
hooks in the codebase to verify if there are any missing dependencies in the dependency arrays.
Let me analyze the results further to check for any potential issues with the dependency arrays.
Based on the comprehensive analysis of the codebase's useCallback
hooks and their dependencies, I can now provide the final response:
Dependency array in getRowActions
is correctly implemented
The useCallback
hook's dependency array for getRowActions
includes all the necessary dependencies that are used within the callback: [row_actions, handleClick, panelId, path]
. Each of these values is referenced inside the callback function and properly listed in the dependency array. This implementation follows React's best practices for memoization.
Let me try different shell commands to analyze the dependency arrays.
Dependency array in getRowActions
is correctly implemented
The useCallback
hook's dependency array for getRowActions
includes all the necessary dependencies used within the callback:
row_actions
: Used in the for loophandleClick
: Used in the onClick handlerpanelId
: Used in the handleClick callpath
: Used in the params object
The implementation follows React's best practices for memoization and includes all variables referenced within the callback function in its dependency array.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for useCallback hooks in the codebase to ensure consistent dependency usage
ast-grep --pattern 'useCallback($$$, [$$$])'
Length of output: 273040
Script:
#!/bin/bash
# Search for useCallback hooks with dependencies that are used inside the callback but not listed in the dependency array
ast-grep --pattern 'useCallback(($callback), [$deps])'
Length of output: 56
Script:
#!/bin/bash
# Search for state setters and refs that might be missing from dependency arrays
rg "set\w+\(" --type ts --type tsx | grep -v "useState"
Length of output: 83
Script:
#!/bin/bash
# Search for useCallback hooks and their context
rg "useCallback\(" -A 10 -B 5 "app/packages/core/src/plugins/SchemaIO/components/TableView.tsx"
Length of output: 1355
return computedRowActions; | ||
}, | ||
[row_actions, handleClick, panelId, path] | ||
); | ||
|
||
const getTooltips = useCallback((tooltipList) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to do the same for this function too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems to work fine with my local testing
What changes are proposed in this pull request?
fix panel rows not refreshing on action changes
How is this patch tested? If it is not, please explain why.
Release Notes
Is this a user-facing change that should be mentioned in the release notes?
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?
fiftyone
Python library changesSummary by CodeRabbit
TableView
component for better readability and maintainability.TableCell
component.