-
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
Persist current slice during group modal navigation #4836
Conversation
WalkthroughThe changes involve modifications to 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 (1)
app/packages/state/src/hooks/useSetExpandedSample.ts (1)
Line range hint
1-55
: Consider minor improvements for clarity and maintainabilityWhile the current implementation is solid, consider the following suggestions to further enhance the code:
If the
THREE_D
set is used in other parts of the application, consider moving it to a separate constants file for better reusability and maintainability.The state management logic, especially the fallback selection process, is quite complex. Adding some comments to explain the purpose and logic of these operations would improve code readability and make it easier for other developers to understand and maintain the code.
Example:
// Select a non-3D fallback when the current media type is 3D if (THREE_D.has(map[fallback])) { // Find the first non-3D media type as a fallback fallback = types .filter(({ mediaType }) => !THREE_D.has(mediaType)) .map(({ name }) => name) .sort()[0]; set(groupAtoms.modalGroupSlice, fallback); }These changes would improve the overall clarity and maintainability of the code without affecting its functionality.
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (2)
- app/packages/state/src/hooks/useSetExpandedSample.ts (1 hunks)
- e2e-pw/src/oss/specs/smoke-tests/quickstart-groups.spec.ts (1 hunks)
Additional context used
Path-based instructions (2)
app/packages/state/src/hooks/useSetExpandedSample.ts (1)
Pattern
**/*.{ts,tsx}
: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.e2e-pw/src/oss/specs/smoke-tests/quickstart-groups.spec.ts (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 not posted (3)
app/packages/state/src/hooks/useSetExpandedSample.ts (2)
31-32
: Approved: Improved logic for handling 3D media typesThe change to move
set(groupAtoms.modalGroupSlice, fallback);
inside the conditional block is a good improvement. This ensures that themodalGroupSlice
is only updated when the current media type is 3D and a non-3D fallback is selected. This change aligns with the PR objective of fixing active slice persistence during group modal navigation.The modification prevents unnecessary updates to the
modalGroupSlice
when dealing with non-3D media types, which should lead to more predictable behavior and better performance.
Line range hint
1-55
: Approved: Well-structured custom hook implementationThe overall structure and implementation of the
useSetExpandedSample
hook adhere to React and Recoil best practices:
- It effectively uses
useRecoilCallback
for managing complex state updates.- The
commit
function is separated from thesetter
, promoting a clear separation of concerns.- The returned function is wrapped in
useCallback
, optimizing performance by preventing unnecessary recreations.This implementation should provide efficient and predictable state management for the group modal navigation feature.
e2e-pw/src/oss/specs/smoke-tests/quickstart-groups.spec.ts (1)
95-101
: LGTM! The added test case aligns well with the PR objectives.The new test steps effectively validate the persistence of the active slice during group modal navigation, which is the main goal of this pull request. The implementation follows the existing testing patterns and provides good coverage for the described scenario.
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.
LGTM
What changes are proposed in this pull request?
Fixes active slice persistence in the group modal
Screen.Recording.2024-09-24.at.2.28.02.PM.mov
How is this patch tested? If it is not, please explain why.
e2e assertion
Release Notes
What areas of FiftyOne does this PR affect?
fiftyone
Python library changesSummary by CodeRabbit