Skip to content

Fix <ReferenceFieldBase> does not work offline - #11163

Merged
slax57 merged 1 commit into
masterfrom
fix-reference-field-offline
Feb 16, 2026
Merged

Fix <ReferenceFieldBase> does not work offline#11163
slax57 merged 1 commit into
masterfrom
fix-reference-field-offline

Conversation

@fzaninotto

Copy link
Copy Markdown
Member

Problem

ReferenceField hides the (stale) data when the network returns an error. This is not the default behavior of TanStack Query, and this means that ReferenceField will always render empty in offline.

Solution

If the query returns data, even in case of error, return it.

## Problem

ReferenceField hides the (stale) data when the network returns an error. This is not the default behavior of TanStack Query, and this means that ReferenceField will always render empty in offline.

## Solution

If the query returns data, even in case of error, return it.

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 offline rendering for ReferenceField by ensuring useReference returns cached/placeholder reference data even when the underlying query is in an error state (e.g., network failure while offline), aligning with TanStack Query’s default “keep data on error” behavior.

Changes:

  • Update useReference to no longer hide referenceRecord when error is set.
  • Preserve stale/cached reference data for offline and refetch-error scenarios.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/ra-core/src/controller/useReference.ts
@slax57 slax57 added this to the 5.14.2 milestone Feb 16, 2026
@slax57
slax57 merged commit 2b146fb into master Feb 16, 2026
21 checks passed
@slax57
slax57 deleted the fix-reference-field-offline branch February 16, 2026 08:58
@slax57 slax57 changed the title Fix ReferenceField does not work offline Fix <ReferenceFieldBase> does not work offline Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RFR Ready For Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants