Fix search showing limited results#1139
Conversation
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The
submitSearchValuelogic (resetting page to 1 and usingstartIdx: 0/stopIdx: perPage) is duplicated across many pages; consider extracting a shared hook or helper to keep this behavior consistent and easier to maintain. - Where the page number is shown in the UI, verify that resetting
setPage(1)on search aligns with user expectations (e.g., when clearing search or changing filters) so pagination indicators don’t become inconsistent with the underlying data.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `submitSearchValue` logic (resetting page to 1 and using `startIdx: 0`/`stopIdx: perPage`) is duplicated across many pages; consider extracting a shared hook or helper to keep this behavior consistent and easier to maintain.
- Where the page number is shown in the UI, verify that resetting `setPage(1)` on search aligns with user expectations (e.g., when clearing search or changing filters) so pagination indicators don’t become inconsistent with the underlying data.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
1371ef1 to
5823bdc
Compare
There was a problem hiding this comment.
Hi, I tried the changes and the bug seems to be still there, I was trying it in the hbac rules pages.
Screencast.From.2026-07-13.15-54-53.mp4
upon the first enter, it just changes to the first page and upon the second click it actually searches for the name
EDIT: the active users are working, I think this difference might be because of the responsive search upon each keystroke? but that is just a guess
| startIdx: firstIdx, | ||
| stopIdx: lastIdx, | ||
| startIdx: 0, | ||
| stopIdx: perPage, |
There was a problem hiding this comment.
Won't this limit the search to only perPage entries? What if I have more entries than that? How can I search for them?
There was a problem hiding this comment.
You are right. Not sure why this was changed like that...
18fb8c3 to
da4d9d7
Compare
veronnicka
left a comment
There was a problem hiding this comment.
Thanks, I tried Active users and Hbac rules pages again and it works as expected. You even fixed the responsive search, so we should add Fixes: #1138
I think there is a redundant setPage(1) in the solution so please look into that.
I noticed that the changes are not consistent and decided to dig a bit into it, then I also noticed some files were not touched and are still not working, I am sending a screenshot from Claude:
I checked the OtpTokens in the UI and the bug is still present. The list is just orientational, but a good starting point. I suggest asking claude for incosistencies and then check it and make sure all files are fixed.
| } | ||
|
|
||
| setUsersTotalCount(totalCount); | ||
| setPage(1); |
There was a problem hiding this comment.
why is it here again? you already set it at the begginning of the call
There was a problem hiding this comment.
This is because, when a search is done from, e.g, page 2, the results are listed (and most likely will be one or more entries, but less than what's specified in perPage, e.g. 10), but the page is still located in 2 so the results cannot be seen. That's why I'm settings the page to the very beginning so that the data can be shown.
There was a problem hiding this comment.
yes that I understand. But the setPage is done twice in the call, once at the very begginning a few lines up, and then again here.
I didn't realized about the responsive search until you mentioned it, haha. I have already fixed the changes mentioned and I have tested it in |
| > **Important — `stopIdx: 100`:** Use a fixed upper bound (100) instead of `perPage`. | ||
| > The LDAP backend has a size limit close to this value, and using `perPage` (e.g. 10) | ||
| > would miss entries beyond the first page of results when searching from a page other | ||
| > than page 1. |
There was a problem hiding this comment.
Right. But even if you put a wild number like, e.g. 1000 there, the limitation will be around ~200 elements.
I dont see any recent push(aybe some issue on my end?), will wait for that then check. |
I pushed them. But I can do the push again... |
63d00a2 to
ba2ccff
Compare
veronnicka
left a comment
There was a problem hiding this comment.
Hi, I tried running it, looked into Hbac rules, Active users, User groups and all seems to work great. Thanks for the effort. Just one comment in the doc, please add the Fixes: as I suggested, other than that we can merge. Providing an ack
| elementsList: entities, | ||
| totalCount: searchTotalCount, | ||
| }); | ||
| setPage(1); |
There was a problem hiding this comment.
the code no longer calls the setPage in the success branch so please remove from the doc as well
Fix search from non-first pages returning wrong or empty results Reset pagination to page 1 and use `startIdx: 0` when submitting a search. Previously, search used the current page offset, which skipped matching entries in the LDAP result set. Fixed across all affected pages, and updated the corresponding `main-pages` file. Assisted-by: Claude <noreply@anthropic.com> Signed-off-by: Carla Martinez <carlmart@redhat.com>
ba2ccff to
a74c373
Compare


Fix search from non-first pages returning
wrong or empty results
Reset pagination to page 1 and use
startIdx: 0when submitting a search. Previously, search used
the current page offset, which skipped matching
entries in the LDAP result set. Fixed across all
affected pages, and updated the corresponding
main-pagesfile.Assisted-by: Claude noreply@anthropic.com
Summary by Sourcery
Reset search pagination and result indices so searches always start from the first page and return complete results across all affected listing pages.
Bug Fixes:
Documentation: