-
Notifications
You must be signed in to change notification settings - Fork 5
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: apply search after loading new batch of referenda #1597
Conversation
WalkthroughThe changes involve modifications to the Changes
Assessment against linked issues
Poem
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
CodeRabbit Configuration File (
|
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)
packages/extension-polkagate/src/fullscreen/governance/SearchBox.tsx (3)
141-147
: LGTM with a suggestion: New effect for reapplying search.This new
useEffect
hook successfully addresses the PR's main objective by reapplying the search when new referenda are loaded. Great job!However, consider optimizing the
onSearch
function withuseCallback
to prevent unnecessary re-renders of this effect.You could wrap the
onSearch
function withuseCallback
like this:const onSearch = useCallback((keyword: string) => { // ... existing onSearch logic ... }, [filter, referenda, setFilteredReferenda]);This will ensure that
onSearch
is only recreated when its dependencies change, potentially reducing unnecessary effect triggers.
165-165
: LGTM with a suggestion: Updated placeholder text with translation.The use of the translation function for the placeholder text improves internationalization. Good job!
Consider specifying the type argument for the
t
function to ensure proper type inference:placeholder={t<string>('🔍 Search in all referenda ')}This will help maintain type safety and improve code clarity.
166-168
: Consider removing or implementing the commented-out code.There's a commented-out line that suggests the
InputFilter
component's value is not being controlled. This might lead to inconsistencies between the displayed value and the stored state.Consider either:
- Removing the commented-out line if it's not needed, or
- Implementing it to make the
InputFilter
a controlled component:value={searchKeyword ?? ''}This will ensure that the input value always reflects the current state.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- packages/extension-polkagate/src/fullscreen/governance/SearchBox.tsx (4 hunks)
🧰 Additional context used
🔇 Additional comments (2)
packages/extension-polkagate/src/fullscreen/governance/SearchBox.tsx (2)
51-54
: LGTM: New state variable for search keyword.The addition of the
searchKeyword
state variable is well-placed and correctly typed. This change aligns with the PR objective of improving search functionality for referenda.
92-93
: LGTM: Updating search keyword state.The addition of
setSearchKeyword(keyword)
in theonSearch
function ensures that the search term is properly stored in the component's state. This change supports the PR's objective of maintaining search functionality across referenda updates.
closes #1220
Summary by CodeRabbit
New Features
Improvements