-
Notifications
You must be signed in to change notification settings - Fork 3.5k
waleedlatif1/hangzhou v2 #3647
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
waleedlatif1/hangzhou v2 #3647
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Split searchInput (controlled input) from searchQuery (committed value) so the hook only fires on Search click or Enter, not every keystroke - Gate table render on searchQuery.length > 0 to prevent stale results showing after input is cleared Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,6 +31,7 @@ export function Admin() { | |||||||||||
|
|
||||||||||||
| const [workflowId, setWorkflowId] = useState('') | ||||||||||||
| const [usersOffset, setUsersOffset] = useState(0) | ||||||||||||
| const [searchInput, setSearchInput] = useState('') | ||||||||||||
| const [searchQuery, setSearchQuery] = useState('') | ||||||||||||
| const [banUserId, setBanUserId] = useState<string | null>(null) | ||||||||||||
| const [banReason, setBanReason] = useState('') | ||||||||||||
|
|
@@ -41,6 +42,11 @@ export function Admin() { | |||||||||||
| error: usersError, | ||||||||||||
| } = useAdminUsers(usersOffset, PAGE_SIZE, searchQuery) | ||||||||||||
|
|
||||||||||||
| const handleSearch = () => { | ||||||||||||
| setUsersOffset(0) | ||||||||||||
| setSearchQuery(searchInput.trim()) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| const totalPages = useMemo( | ||||||||||||
| () => Math.ceil((usersData?.total ?? 0) / PAGE_SIZE), | ||||||||||||
| [usersData?.total] | ||||||||||||
|
|
@@ -128,14 +134,17 @@ export function Admin() { | |||||||||||
|
|
||||||||||||
| <div className='flex flex-col gap-[12px]'> | ||||||||||||
| <p className='font-medium text-[14px] text-[var(--text-primary)]'>User Management</p> | ||||||||||||
| <EmcnInput | ||||||||||||
| value={searchQuery} | ||||||||||||
| onChange={(e) => { | ||||||||||||
| setSearchQuery(e.target.value) | ||||||||||||
| setUsersOffset(0) | ||||||||||||
| }} | ||||||||||||
| placeholder='Search by email or paste a user ID...' | ||||||||||||
| /> | ||||||||||||
| <div className='flex gap-[8px]'> | ||||||||||||
| <EmcnInput | ||||||||||||
| value={searchInput} | ||||||||||||
| onChange={(e) => setSearchInput(e.target.value)} | ||||||||||||
| onKeyDown={(e) => e.key === 'Enter' && handleSearch()} | ||||||||||||
| placeholder='Search by email or paste a user ID...' | ||||||||||||
| /> | ||||||||||||
| <Button variant='primary' onClick={handleSearch} disabled={usersLoading}> | ||||||||||||
| {usersLoading ? 'Searching...' : 'Search'} | ||||||||||||
| </Button> | ||||||||||||
|
Comment on lines
+144
to
146
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The Search button is currently enabled whenever
Suggested change
|
||||||||||||
| </div> | ||||||||||||
|
|
||||||||||||
| {usersError && ( | ||||||||||||
| <p className='text-[13px] text-[var(--text-error)]'> | ||||||||||||
|
|
@@ -158,7 +167,7 @@ export function Admin() { | |||||||||||
| </div> | ||||||||||||
| )} | ||||||||||||
|
|
||||||||||||
| {usersData && ( | ||||||||||||
| {searchQuery.length > 0 && usersData && ( | ||||||||||||
| <> | ||||||||||||
| <div className='flex flex-col gap-[2px]'> | ||||||||||||
| <div className='flex items-center gap-[12px] border-[var(--border-secondary)] border-b px-[12px] py-[8px] text-[12px] text-[var(--text-tertiary)]'> | ||||||||||||
|
|
||||||||||||
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.
The
onKeyDownhandler fireshandleSearchwhen Enter is pressed regardless of whethersearchInputhas content. This has the same side-effect as the empty button click: it resetsusersOffsetto 0 and setssearchQueryto'', making any previously visible results disappear. Adding asearchInput.trim()guard before callinghandleSearchkeeps keyboard and click behaviour consistent.