Bug: Do not increment page when fetching is not done - #181
Merged
Conversation
…ge to Table component
Co-authored-by: Alex Dunae <alex@dunae.ca>
…on_in_cell_view_itwingrid_2025-09-23-23-29.json
alexdunae
reviewed
Oct 10, 2025
…ithub.com/iTwin/admin-components-react into hans/fix_imodel_fetch_when_not_yet_loaded
hansrajkvb
marked this pull request as ready for review
October 10, 2025 16:51
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug in the IModelGrid where pagination incorrectly increments when prerequisites (access token or iTwin ID) are not yet available, causing the first page of data to be skipped.
- Added early return conditions to prevent page increment when token or context is not available
- Added comprehensive test coverage for both missing access token and iTwin ID scenarios
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| useIModelData.ts | Added status checks for TokenRequired and ContextRequired to prevent premature page incrementation |
| useIModelData.test.ts | Added parameterized test to verify pagination behavior when prerequisites are missing |
| hans-fix_imodel_fetch_when_not_yet_loaded_2025-10-10-02-55.json | Added changelog entry documenting the bug fix |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
aruniverse
approved these changes
Oct 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
In the IModelGrid, when the access token or itwinid does not get loaded in time (usually on first render), no fetching occurs, but
pagestill gets incremented.When
pagegets incremented,$skipalso gets incremented to ignore the first page of imodels. But in this case the fetching never happened, so the first page of imodels is never fetched.Fix
When access token or itwinid is not yet loaded, return early so that
pageis not incorrectly incremented.