Skip to content
Source
Sign inSign up
TanStack/form

fix(form-core): 🐛 File input field - Picking a different file does not trigger rerender (deep equality issue with File/Blob objects) #1939

ClosedjoaoGabriel55(GitHub profile, opens in a new tab)wants to merge 11 commits intomain fromrefs/pull/1939/headopened

Showing 4 changed files with 43 additions and 0 deletions (loading 1).

x
0 of 4 viewed, 4 left
5 additions and 0 deletions.changeset/some-ducks-write.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/form-core': patch
+---
+​
+Fix File/Blob equality in change detection
12 additions and 0 deletionspackages/form-core/src/utils.tsModified
View file
@@ -435,6 +435,18 @@
return false
​
+ // Blob (and File, which extends Blob) objects have no own enumerable keys,
+ // so the generic key-comparison below would incorrectly consider any two
+ // Blob/File instances as equal. Fall back to referential identity (already
+ // handled by Object.is above, which returned false).
+ if (
+ typeof Blob !== 'undefined' &&
+ objA instanceof Blob &&
+ objB instanceof Blob
+ ) {
+ return false
+ }
+​
if (objA instanceof Date && objB instanceof Date) {