Fix <Edit>, <ReferenceField> and <List> to better support offline mode#11161
Open
fzaninotto wants to merge 13 commits intomasterfrom
Open
Fix <Edit>, <ReferenceField> and <List> to better support offline mode#11161fzaninotto wants to merge 13 commits intomasterfrom
<Edit>, <ReferenceField> and <List> to better support offline mode#11161fzaninotto wants to merge 13 commits intomasterfrom
Conversation
slax57
approved these changes
Feb 17, 2026
<Edit>, <ReferenceField> and <List> to better support offline mode
WiXSL
requested changes
Feb 18, 2026
| const getRecordRepresentation = useGetRecordRepresentation(reference); | ||
|
|
||
| if (error) { | ||
| if (error && referenceRecord == null) { |
Collaborator
There was a problem hiding this comment.
When the app is online and a cached referenceRecord exists, it can hide real API errors
// Potencial Fix
if (error && (referenceRecord == null || !referenceFieldContext.isPaused)) {
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.
Problem
Offline apps behave in a strange way, sometimes showing error pages even though they should not.
The offline mode of TanStack Query works fine in a standalone example, so the problems come from react-admin.
We lack a way to properly test offline mode, particularly in the context of a PWA.
Additional specific issues found:
<Edit>ignores theredirectOnErrorprop, making it hard to disable the redirection to the list in case of error (even if there's data in the cache)<ReferenceField>renders an error message even if the reference record is available in the cache<ListView>hides the pagination as soon as a fetch error occurs, preventing the user to go back to a page for which cached data are presentSolution
Build a demo (with Vite PWA plugin), track down the issues and fix them.
When offline, all calls to useQuery return an error... but they also return data.
In a nutshell, we must not only check for errors before deciding to show/return things but also that no data is available for offline support to work correctly
If we have a NetworkError and valid data, it means we're offline and that TanStack query returned stale data.
How To Test
make build-offlinemake preview-offline(the offline mode doesn't work in dev mode, that's a limitation of vite-pwa)
Use the DevTools to simulate Offline mode when needed.
The PWA should be able to fetch data from the cache, even when reloading the whole app while offline (thanks to the service worker and the TanStack query Persister).
Known issue: TanStack query discards the cached data if you reload the app 2 times. See related issue.
The PWA should allow to perform mutations while offline, and replay the mutations when back online.
Note: Since this demo is hooked up to JSONPlaceholder API, the changes are not persisted for real. But the mutation should be visible in the Network tab and not trigger errors.
Additional Checks
masterfor a bugfix or a documentation fix, ornextfor a feature