-
Notifications
You must be signed in to change notification settings - Fork 590
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
allow passing title to ButtonView when disabled #5073
Conversation
WalkthroughThe changes introduced in this pull request enhance the modal and button view components by adding a new optional Changes
Possibly related PRs
Suggested labels
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 (3)
app/packages/core/src/plugins/SchemaIO/components/ButtonView.tsx (1)
41-41
: LGTM! Consider adding prop validation.The direct passing of the title prop aligns with the PR objective to show tooltips for disabled buttons. However, consider adding proper TypeScript validation:
+ interface ButtonViewProps extends ViewPropsType { + schema: { + view?: { + title?: string; + // ... other existing view props + }; + }; + } - export default function ButtonView(props: ViewPropsType) { + export default function ButtonView(props: ButtonViewProps) {app/packages/components/src/components/ModalBase/ModalBase.tsx (2)
108-108
: Consider adding documentation and validation for the title propertyWhile the implementation correctly enables passing titles to ButtonView, consider these improvements:
- Add JSDoc comments explaining the purpose of the title property
- Add validation to ensure the title is a non-empty string when provided
Example implementation:
+ // Title to be displayed in the button tooltip, shown even when button is disabled title: props?.title, + // Validate title if provided + ...(props?.title && typeof props.title !== 'string' && { + title: String(props.title) + }),
Line range hint
171-184
: Fix useEffect dependency array to prevent stale closuresThe effect uses
primaryButtonView
object but only listsprimaryButtonView.params
in its dependency array. This could lead to stale closures if other properties ofprimaryButtonView
change.Update the dependency array to include all used values:
useEffect(() => { if ( (functionality === "tagging" || functionality === "Tagging") && (!primaryButtonView.params || !primaryButtonView.params.tags || primaryButtonView.params.tags.length === 0) ) { setPrimaryButtonView({ ...primaryButtonView, disabled: true, }); } else { setPrimaryButtonView({ ...primaryButtonView, disabled: false, }); } - }, [primaryButtonView.params]); + }, [primaryButtonView, functionality]);
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (2)
app/packages/components/src/components/ModalBase/ModalBase.tsx
(2 hunks)app/packages/core/src/plugins/SchemaIO/components/ButtonView.tsx
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
app/packages/components/src/components/ModalBase/ModalBase.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/ButtonView.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 (2)
app/packages/core/src/plugins/SchemaIO/components/ButtonView.tsx (1)
Line range hint 41-63
: Add test coverage for tooltip behavior.
Please ensure test coverage for:
- Tooltip visibility when button is disabled
- Correct title rendering in both enabled/disabled states
app/packages/components/src/components/ModalBase/ModalBase.tsx (1)
52-52
: LGTM: Interface change follows TypeScript best practices
The addition of the optional title
property to the ModalButtonView
interface is well-structured and properly typed.
What changes are proposed in this pull request?
Screen.Recording.2024-11-07.at.3.47.20.PM.mov
How is this patch tested? If it is not, please explain why.
(Details)
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
New Features
title
property for button views in modals, enhancing configuration flexibility.Bug Fixes