-
Notifications
You must be signed in to change notification settings - Fork 83
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
chore(weave): add highlight state when editing filters #3889
Conversation
WalkthroughThis pull request introduces a new state variable Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant FB as FilterBar
participant FTI as FilterTagItem
participant FT as FilterTag
U->>FB: Triggers filter edit (onUpdateFilter)
FB-->>FB: Sets activeEditId to filter ID
FB->>FTI: Passes isEditing prop based on activeEditId
FTI->>FT: Forwards isEditing to adjust display
U->>FB: Removes a filter (onRemoveFilter)
FB-->>FB: Resets activeEditId if filter removed
U->>FB: Closes popover (onSetSelected)
FB-->>FB: Clears activeEditId
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 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 comments (1)
weave-js/src/components/PagePanelComponents/Home/Browse3/filters/FilterBar.tsx (1)
211-212
:⚠️ Potential issueInclude
activeEditId
in dependency array.The
onUpdateFilter
callback referencesactiveEditId
but it's not included in the dependency array, which could lead to stale closures.}, - [localFilterModel, updateLocalAndDebouncedFilterModel] + [localFilterModel, updateLocalAndDebouncedFilterModel, activeEditId] );
🧹 Nitpick comments (1)
weave-js/src/components/PagePanelComponents/Home/Browse3/filters/FilterBar.tsx (1)
253-254
: Avoid duplicate state cleanup logic.The
activeEditId
is cleared in bothonSetSelected
and thePopover
'sonClose
handler. This is redundant assetAnchorEl(null)
will trigger theonClose
event.setAnchorEl(null); - // Clear active edit when popover is closed - setActiveEditId(null);
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
weave-js/src/components/PagePanelComponents/Home/Browse3/filters/FilterBar.tsx
(6 hunks)weave-js/src/components/PagePanelComponents/Home/Browse3/filters/FilterTag.tsx
(1 hunks)weave-js/src/components/PagePanelComponents/Home/Browse3/filters/FilterTagItem.tsx
(3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{js,jsx,ts,tsx}`: Focus on architectural and logical i...
**/*.{js,jsx,ts,tsx}
: Focus on architectural and logical issues rather than style (assuming ESLint is in place).
Flag potential memory leaks and performance bottlenecks.
Check for proper error handling and async/await usage.
Avoid strict enforcement of try/catch blocks - accept Promise chains, early returns, and other clear error handling patterns. These are acceptable as long as they maintain clarity and predictability.
Ensure proper type usage in TypeScript files.
Look for security vulnerabilities in data handling.
Don't comment on formatting if prettier is configured.
Verify proper React hooks usage and component lifecycle.
Check for proper state management patterns.
weave-js/src/components/PagePanelComponents/Home/Browse3/filters/FilterTagItem.tsx
weave-js/src/components/PagePanelComponents/Home/Browse3/filters/FilterTag.tsx
weave-js/src/components/PagePanelComponents/Home/Browse3/filters/FilterBar.tsx
⏰ Context from checks skipped due to timeout of 90000ms (90)
- GitHub Check: WeaveJS Lint and Compile
- GitHub Check: Trace nox tests (3, 13, trace)
- GitHub Check: Trace nox tests (3, 12, scorers)
- GitHub Check: Trace nox tests (3, 12, trace)
- GitHub Check: Trace nox tests (3, 11, scorers)
- GitHub Check: Trace nox tests (3, 11, trace)
- GitHub Check: Trace nox tests (3, 10, scorers)
- GitHub Check: Trace nox tests (3, 10, trace)
- GitHub Check: Trace nox tests (3, 9, scorers)
- GitHub Check: WeaveJS Lint and Compile
- GitHub Check: Trace nox tests (3, 13, trace)
- GitHub Check: Trace nox tests (3, 12, scorers)
- GitHub Check: Trace nox tests (3, 12, trace)
- GitHub Check: Trace nox tests (3, 11, scorers)
- GitHub Check: Trace nox tests (3, 11, trace)
- GitHub Check: Trace nox tests (3, 10, scorers)
- GitHub Check: Trace nox tests (3, 10, trace)
- GitHub Check: Trace nox tests (3, 9, scorers)
- GitHub Check: WeaveJS Lint and Compile
- GitHub Check: Trace nox tests (3, 13, trace)
- GitHub Check: Trace nox tests (3, 12, scorers)
- GitHub Check: Trace nox tests (3, 12, trace)
- GitHub Check: Trace nox tests (3, 11, scorers)
- GitHub Check: Trace nox tests (3, 11, trace)
- GitHub Check: Trace nox tests (3, 10, scorers)
- GitHub Check: Trace nox tests (3, 10, trace)
- GitHub Check: Trace nox tests (3, 9, scorers)
- GitHub Check: WeaveJS Lint and Compile
- GitHub Check: Trace nox tests (3, 13, trace)
- GitHub Check: Trace nox tests (3, 12, scorers)
- GitHub Check: Trace nox tests (3, 12, trace)
- GitHub Check: Trace nox tests (3, 11, scorers)
- GitHub Check: Trace nox tests (3, 11, trace)
- GitHub Check: Trace nox tests (3, 10, scorers)
- GitHub Check: Trace nox tests (3, 10, trace)
- GitHub Check: Trace nox tests (3, 9, scorers)
- GitHub Check: WeaveJS Lint and Compile
- GitHub Check: Trace nox tests (3, 13, trace)
- GitHub Check: Trace nox tests (3, 12, scorers)
- GitHub Check: Trace nox tests (3, 12, trace)
- GitHub Check: Trace nox tests (3, 11, scorers)
- GitHub Check: Trace nox tests (3, 11, trace)
- GitHub Check: Trace nox tests (3, 10, scorers)
- GitHub Check: Trace nox tests (3, 10, trace)
- GitHub Check: Trace nox tests (3, 9, scorers)
- GitHub Check: WeaveJS Lint and Compile
- GitHub Check: Trace nox tests (3, 13, trace)
- GitHub Check: Trace nox tests (3, 12, scorers)
- GitHub Check: Trace nox tests (3, 12, trace)
- GitHub Check: Trace nox tests (3, 11, scorers)
- GitHub Check: Trace nox tests (3, 11, trace)
- GitHub Check: Trace nox tests (3, 10, scorers)
- GitHub Check: Trace nox tests (3, 10, trace)
- GitHub Check: Trace nox tests (3, 9, scorers)
- GitHub Check: WeaveJS Lint and Compile
- GitHub Check: Trace nox tests (3, 13, trace)
- GitHub Check: Trace nox tests (3, 12, scorers)
- GitHub Check: Trace nox tests (3, 12, trace)
- GitHub Check: Trace nox tests (3, 11, scorers)
- GitHub Check: Trace nox tests (3, 11, trace)
- GitHub Check: Trace nox tests (3, 10, scorers)
- GitHub Check: Trace nox tests (3, 10, trace)
- GitHub Check: Trace nox tests (3, 9, scorers)
- GitHub Check: WeaveJS Lint and Compile
- GitHub Check: Trace nox tests (3, 13, trace)
- GitHub Check: Trace nox tests (3, 12, scorers)
- GitHub Check: Trace nox tests (3, 12, trace)
- GitHub Check: Trace nox tests (3, 11, scorers)
- GitHub Check: Trace nox tests (3, 11, trace)
- GitHub Check: Trace nox tests (3, 10, scorers)
- GitHub Check: Trace nox tests (3, 10, trace)
- GitHub Check: Trace nox tests (3, 9, scorers)
- GitHub Check: WeaveJS Lint and Compile
- GitHub Check: Trace nox tests (3, 13, trace)
- GitHub Check: Trace nox tests (3, 12, scorers)
- GitHub Check: Trace nox tests (3, 12, trace)
- GitHub Check: Trace nox tests (3, 11, scorers)
- GitHub Check: Trace nox tests (3, 11, trace)
- GitHub Check: Trace nox tests (3, 10, scorers)
- GitHub Check: Trace nox tests (3, 10, trace)
- GitHub Check: Trace nox tests (3, 9, scorers)
- GitHub Check: WeaveJS Lint and Compile
- GitHub Check: Trace nox tests (3, 13, trace)
- GitHub Check: Trace nox tests (3, 12, scorers)
- GitHub Check: Trace nox tests (3, 12, trace)
- GitHub Check: Trace nox tests (3, 11, scorers)
- GitHub Check: Trace nox tests (3, 11, trace)
- GitHub Check: Trace nox tests (3, 10, scorers)
- GitHub Check: Trace nox tests (3, 10, trace)
- GitHub Check: Trace nox tests (3, 9, scorers)
🔇 Additional comments (11)
weave-js/src/components/PagePanelComponents/Home/Browse3/filters/FilterTag.tsx (2)
9-9
: Well structured TypeScript prop definition.The optional boolean prop is correctly typed with the TypeScript optional modifier.
12-20
: Good implementation of the highlight state feature.The component correctly:
- Destructures the new
isEditing
prop with a proper default value- Uses a conditional to set the tag color based on the editing state
This provides clear visual feedback to users when they're editing a filter.
weave-js/src/components/PagePanelComponents/Home/Browse3/filters/FilterTagItem.tsx (3)
29-29
: Consistent prop typing pattern.The optional
isEditing
prop is correctly defined with the TypeScript optional modifier, maintaining consistency with the parent component.
39-43
: Clean prop destructuring with default value.The function signature properly destructures the props including the new
isEditing
prop with a default value offalse
.
72-72
: Proper prop forwarding.The
isEditing
prop is correctly passed to the childFilterTag
component, ensuring the visual state is properly propagated.weave-js/src/components/PagePanelComponents/Home/Browse3/filters/FilterBar.tsx (6)
67-67
: Good state management with clear typing.The new state variable
activeEditId
is correctly initialized withnull
and properly typed asFilterId | null
.
194-196
: Good implementation of active filter tracking.Setting the active edit ID when a filter is updated provides the foundation for the highlight state feature.
221-225
: Properly clean up editing state.Good handling of the edge case where the active filter is removed, ensuring the UI state remains consistent.
226-226
: Correctly updated dependency array.The dependency array properly includes
activeEditId
, ensuring the callback has access to the latest state.
286-286
: Proper prop passing to child component.The
isEditing
prop is correctly passed to theFilterTagItem
component based on comparison with theactiveEditId
.
311-314
: Consolidated state management.Good implementation of the
onClose
handler to clear both the anchor element and the active edit ID when the popover is closed.
Preview this PR with FeatureBee: https://beta.wandb.ai/?betaVersion=14c54b4f108187ac359a32e6c0bf1d3c6c765007 |
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.
I wonder if we can leverage the :focus
pseudo-class instead of a React state to do this. It would be more minimal, lower level, and more centralized (meaning we wouldn't have to do this for each individual field).
Alternatively, what about the focus
and blur
events?
Played around with this, afaict using |
Ah yeah, I see we're using a |
Description
WB-23846
Add highlight state when editing filter.
Testing
Summary by CodeRabbit
New Features
Style