-
Notifications
You must be signed in to change notification settings - Fork 427
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
Add filter input to group members table #9102
Conversation
Add a search box to filter group members. The filter currently only matches the username, is applied client-side and is case-insensitive.
The filtering and member count are currently implemented client side, but once we have pagination they will need to be implemented server-side. This means we will probably need to temporarily remove this until more critical functionality is implemented. |
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.
👍🏼
const normalizedFilter = filter.toLowerCase(); | ||
|
||
const filteredMembers = useMemo(() => { | ||
if (!normalizedFilter || !members) { | ||
return members; | ||
} | ||
// nb. We can get away with lower-casing name and filter to do | ||
// case-insensitive search because of the character set restrictions on | ||
// usernames. This would be incorrect for Unicode text. | ||
return members.filter(m => | ||
m.username.toLowerCase().includes(normalizedFilter), | ||
); | ||
}, [normalizedFilter, members]); |
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.
Since normalizedFilter
is used only inside the callback to calculate filteredMembers
, maybe it's worth moving it there and make filter
the dependency instead of normalizedFilter
.
const normalizedFilter = filter.toLowerCase(); | |
const filteredMembers = useMemo(() => { | |
if (!normalizedFilter || !members) { | |
return members; | |
} | |
// nb. We can get away with lower-casing name and filter to do | |
// case-insensitive search because of the character set restrictions on | |
// usernames. This would be incorrect for Unicode text. | |
return members.filter(m => | |
m.username.toLowerCase().includes(normalizedFilter), | |
); | |
}, [normalizedFilter, members]); | |
const filteredMembers = useMemo(() => { | |
if (!filter || !members) { | |
return members; | |
} | |
// nb. We can get away with lower-casing name and filter to do | |
// case-insensitive search because of the character set restrictions on | |
// usernames. This would be incorrect for Unicode text. | |
const normalizedFilter = filter.toLowerCase(); | |
return members.filter(m => | |
m.username.toLowerCase().includes(normalizedFilter), | |
); | |
}, [filter, members]); |
Add a search box to filter group members. The filter currently only matches the username, is applied client-side and is case-insensitive.
Filter not applied:
Filter applied with match:
Filter applied with no matches: