-
Notifications
You must be signed in to change notification settings - Fork 557
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
SliderView tweaks #4901
SliderView tweaks #4901
Conversation
WalkthroughThe changes introduced in this pull request involve modifications to two components: Changes
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: 2
🧹 Outside diff range and nitpick comments (1)
app/packages/core/src/plugins/SchemaIO/components/Header.tsx (1)
Line range hint
132-132
: Consider using a more specific type forerrors
The type of
errors
has been changed from[]
toany[]
. While this allows for more flexibility, it reduces type safety. Consider using a more specific type instead ofany[]
. For example:errors: Error[]; // If using standard Error objects // or errors: { message: string; code?: number }[]; // If using a custom error structureThis will provide better type checking and improve code maintainability.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (2)
- app/packages/core/src/plugins/SchemaIO/components/Header.tsx (1 hunks)
- app/packages/core/src/plugins/SchemaIO/components/SliderView.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
app/packages/core/src/plugins/SchemaIO/components/Header.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/SliderView.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.
🪛 Biome
app/packages/core/src/plugins/SchemaIO/components/SliderView.tsx
[error] 201-201: Avoid the delete operator which can impact performance.
(lint/performance/noDelete)
[error] 134-134: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.
See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.(lint/suspicious/noGlobalIsNan)
🔇 Additional comments (1)
app/packages/core/src/plugins/SchemaIO/components/Header.tsx (1)
68-72
: Improved conditional rendering of the labelThe changes introduce a conditional rendering for the
Markdown
component, which is a good improvement. This prevents rendering theMarkdown
component when thelabel
is falsy, adhering to React best practices and potentially improving performance by avoiding unnecessary renders.
} | ||
} else { | ||
const floatValue = parseFloat(value); | ||
if (!isNaN(floatValue)) { |
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.
Use Number.isNaN
instead of isNaN
for accurate type checking
The global isNaN
function performs type coercion, which can lead to unexpected results. Using Number.isNaN
ensures that the check is performed without type coercion, making it safer for numerical validations.
Apply this diff to fix the issue:
- if (!isNaN(floatValue)) {
+ if (!Number.isNaN(floatValue)) {
📝 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.
if (!isNaN(floatValue)) { | |
if (!Number.isNaN(floatValue)) { |
🧰 Tools
🪛 Biome
[error] 134-134: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.
See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.(lint/suspicious/noGlobalIsNan)
); | ||
|
||
if (labelPosition === "left") { | ||
delete props?.schema?.view?.label; |
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.
Avoid using the delete
operator; consider alternative approaches
Using the delete
operator can impact performance in JavaScript. Instead of deleting the property, consider setting it to undefined
or creating a new object without the label
property.
Apply this diff to refactor the code:
- delete props?.schema?.view?.label;
+ props = {
+ ...props,
+ schema: {
+ ...props.schema,
+ view: {
+ ...props.schema.view,
+ label: undefined,
+ },
+ },
+ };
Alternatively, you can avoid modifying props
directly and adjust the rendering logic to conditionally display the label based on labelPosition
.
📝 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.
delete props?.schema?.view?.label; | |
props = { | |
...props, | |
schema: { | |
...props.schema, | |
view: { | |
...props.schema.view, | |
label: undefined, | |
}, | |
}, | |
}; |
🧰 Tools
🪛 Biome
[error] 201-201: Avoid the delete operator which can impact performance.
(lint/performance/noDelete)
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.
👍🏽
What changes are proposed in this pull request?
@imanjra @lanzhenw @ brian.B feel free to comment/commit/merge
I know @ritch is proposing a solution where a slider would be part of the plotly which would be great! this is improving our in house slider. https://voxel51.atlassian.net/browse/TEAMS-3536
How is this patch tested? If it is not, please explain why.
Manually created a plugin using the slider mimicking data quality panel
Screen.Recording.2024-10-06.at.7.58.34.PM.mov
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
Header
component to conditionally render theMarkdown
component based on the presence of alabel
.SliderView
component with new input fields for minimum and maximum values, allowing for unit selection and dynamic behavior based on view configuration.Bug Fixes
Markdown
component whenlabel
is undefined or null.Documentation