Skip to content

fix(form-core): support value types with a custom equals() method in deep equality - #2261

Draft
FrancoKaddour wants to merge 1 commit into
TanStack:mainfrom
FrancoKaddour:fix/evaluate-custom-equals
Draft

fix(form-core): support value types with a custom equals() method in deep equality#2261
FrancoKaddour wants to merge 1 commit into
TanStack:mainfrom
FrancoKaddour:fix/evaluate-custom-equals

Conversation

@FrancoKaddour

Copy link
Copy Markdown

Closes #2195

Problem

evaluate (the deep-equality helper used for dirty-checking) reports two equal value-type instances as unequal. Value types like Temporal.PlainDate, Luxon DateTime, etc. expose their state through private fields/getters, so they have no own enumerable keys and a non-plain prototype — which hits the no-enumerable-keys guard added in #2140 and returns false. A field backed by such a value is then considered dirty even after it's reset to its original value.

Fix

Before that guard, delegate to a custom equals() method when both operands share a constructor that exposes one. This covers Temporal types, Luxon DateTime, Immutable collections, and any value type following the equals() convention, while leaving plain objects/arrays and the existing Date/Map/Set cases untouched.

Tests

Added a form-core unit test using a value type with a private field and an equals() method (mirroring Temporal's shape — no own enumerable keys). Reverting the fix fails it; the full form-core suite passes, plus typecheck and lint.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: cfc67464-7fc2-434f-8af9-b6a761a968f9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

Value equality does not handle Temporals

1 participant