Skip to content

Fix iModelGrid Filtering to Show Complete Results Across All Data - #176

Merged
aruniverse merged 6 commits into
iTwin:mainfrom
Bentley-Vivek:vp/fix-filtering-issue
Sep 19, 2025
Merged

Fix iModelGrid Filtering to Show Complete Results Across All Data#176
aruniverse merged 6 commits into
iTwin:mainfrom
Bentley-Vivek:vp/fix-filtering-issue

Conversation

@Bentley-Vivek

@Bentley-Vivek Bentley-Vivek commented Sep 17, 2025

Copy link
Copy Markdown
Contributor

This PR fixes two issues with the IModelGrid component's handling of filtering via postProcessCallback:

  1. Incomplete Results: The component was only filtering against the first batch of data and not searching subsequent batches

  2. Premature "No Results": When no matches were found in the first batch, it incorrectly displayed "No iModels" even when matches existed in later batches

Problem Details

When we applied filtering via postProcessCallback (e.g., filtering by description or name of iModel):

  • If matching iModels existed in both 1st batch of iModels and later batches, only the early matches would be shown
  • If no matches existed in the first batch but did exist in later batches, we get "No iModels"

Solution

Added a useEffect to continue loading data when needed:

React.useEffect(() => {
  if (
    iModels.length < pageSize &&
    fetchMore &&
    fetchStatus !== DataStatus.Fetching
  ) {
    fetchMore();
  }
}, [iModels.length, pageSize, fetchMore, fetchStatus]);

Screenshots

Before Fix - Missing Results:
Screenshot 2025-09-17 141321

After Fix - Complete Results:
Screenshot 2025-09-17 141422

@Bentley-Vivek Bentley-Vivek changed the title Fix iModelGrid Filtering via postProcessCallback to Show Complete Results Across All Data Fix iModelGrid Filtering to Show Complete Results Across All Data Sep 17, 2025
@Bentley-Vivek
Bentley-Vivek marked this pull request as ready for review September 17, 2025 09:45
@aruniverse
aruniverse requested a review from Copilot September 17, 2025 16:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes filtering issues in the IModelGrid component where the postProcessCallback was only filtering against the first batch of data, causing incomplete results and premature "No Results" messages.

  • Added a useEffect hook to automatically fetch more data when filtered results are below the page size
  • Exported DEFAULT_PAGE_SIZE constant to support the new filtering logic
  • Added changelog entry documenting the fix

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
useIModelData.ts Exports DEFAULT_PAGE_SIZE constant for use in filtering logic
IModelGrid.tsx Adds useEffect hook to continue fetching data when filtered results are insufficient
vp-fix-filtering-issue_2025-09-17-09-16.json Documents the patch-level change for filtering fix

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@aruniverse
aruniverse requested a review from Copilot September 19, 2025 10:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread packages/modules/imodel-browser/src/containers/iModelGrid/IModelGrid.test.tsx Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@aruniverse
aruniverse enabled auto-merge (squash) September 19, 2025 11:01
auto-merge was automatically disabled September 19, 2025 11:52

Head branch was pushed to by a user without write access

@aruniverse
aruniverse merged commit 464beba into iTwin:main Sep 19, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants