Skip to content

Commit f411db5

Browse files
committed
Merge branch 'master' into precognition-merge
2 parents 834f9a9 + fb95bf6 commit f411db5

File tree

23 files changed

+404
-22
lines changed

23 files changed

+404
-22
lines changed

CHANGELOG.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
For changes prior to v1.0.0, see the [legacy releases](https://legacy.inertiajs.com/releases).
99

10-
## [Unreleased](https://github.com/inertiajs/inertia/compare/v2.2.16...master)
10+
## [Unreleased](https://github.com/inertiajs/inertia/compare/v2.2.18...master)
1111

1212
- Nothing yet
1313

14+
## [v2.2.18](https://github.com/inertiajs/inertia/compare/v2.2.17...v2.2.18) - 2025-11-17
15+
16+
### What's Changed
17+
18+
* Ensure `objectsAreEqual()` checks all keys in both objects by [@pascalbaljet](https://github.com/pascalbaljet) in https://github.com/inertiajs/inertia/pull/2705
19+
20+
**Full Changelog**: https://github.com/inertiajs/inertia/compare/v2.2.17...v2.2.18
21+
22+
## [v2.2.17](https://github.com/inertiajs/inertia/compare/v2.2.16...v2.2.17) - 2025-11-14
23+
24+
### What's Changed
25+
26+
* Reset `<WhenVisible>` loading state after a page reload by [@pascalbaljet](https://github.com/pascalbaljet) in https://github.com/inertiajs/inertia/pull/2699
27+
* Add test for reloading deferred props by [@pascalbaljet](https://github.com/pascalbaljet) in https://github.com/inertiajs/inertia/pull/2698
28+
* Force `indices` array format when submitting data using `FormData` by [@pascalbaljet](https://github.com/pascalbaljet) in https://github.com/inertiajs/inertia/pull/2701
29+
30+
**Full Changelog**: https://github.com/inertiajs/inertia/compare/v2.2.16...v2.2.17
31+
1432
## [v2.2.16](https://github.com/inertiajs/inertia/compare/v2.2.15...v2.2.16) - 2025-11-13
1533

1634
### What's Changed

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@inertiajs/core",
3-
"version": "2.2.16",
3+
"version": "2.2.18",
44
"license": "MIT",
55
"description": "A framework for creating server-driven single page apps.",
66
"contributors": [

packages/core/src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export class Config<TConfig extends {} = {}> {
7373
export const config = new Config<InertiaAppConfig>({
7474
form: {
7575
recentlySuccessfulDuration: 2_000,
76+
forceIndicesArrayFormatInFormData: true,
7677
},
7778
future: {
7879
preserveEqualProps: false,

packages/core/src/objectUtils.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const objectsAreEqual = <T>(
1+
export const objectsAreEqual = <T extends Record<string, any>>(
22
obj1: T,
33
obj2: T,
44
excludeKeys: {
@@ -9,6 +9,7 @@ export const objectsAreEqual = <T>(
99
return true
1010
}
1111

12+
// Check keys in obj1
1213
for (const key in obj1) {
1314
if (excludeKeys.includes(key)) {
1415
continue
@@ -23,6 +24,17 @@ export const objectsAreEqual = <T>(
2324
}
2425
}
2526

27+
// Check keys that exist in obj2 but not in obj1
28+
for (const key in obj2) {
29+
if (excludeKeys.includes(key)) {
30+
continue
31+
}
32+
33+
if (!(key in obj1)) {
34+
return false
35+
}
36+
}
37+
2638
return true
2739
}
2840

packages/core/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ export type PrefetchOptions = {
498498
export type InertiaAppConfig = {
499499
form: {
500500
recentlySuccessfulDuration: number
501+
forceIndicesArrayFormatInFormData: boolean
501502
}
502503
// experimental: {
503504
// /* not guaranteed */

packages/core/src/url.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as qs from 'qs'
2+
import { config } from './config'
23
import { hasFiles } from './files'
34
import { isFormData, objectToFormData } from './formData'
45
import type {
@@ -24,6 +25,10 @@ export const transformUrlAndData = (
2425
let url = typeof href === 'string' ? hrefToUrl(href) : href
2526

2627
if ((hasFiles(data) || forceFormData) && !isFormData(data)) {
28+
if (config.get('form.forceIndicesArrayFormatInFormData')) {
29+
queryStringArrayFormat = 'indices'
30+
}
31+
2732
data = objectToFormData(data, new FormData(), null, queryStringArrayFormat)
2833
}
2934

packages/react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@inertiajs/react",
3-
"version": "2.2.16",
3+
"version": "2.2.18",
44
"license": "MIT",
55
"description": "The React adapter for Inertia.js",
66
"contributors": [

packages/react/test-app/Pages/DeferredProps/Page1.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ export default () => {
2525

2626
<Link href="/deferred-props/page-1">Page 1</Link>
2727
<Link href="/deferred-props/page-2">Page 2</Link>
28+
<Link href="/deferred-props/page-3" prefetch>
29+
Page 3
30+
</Link>
2831
</>
2932
)
3033
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Deferred, usePage } from '@inertiajs/react'
2+
3+
const Alpha = () => {
4+
const { alpha } = usePage<{ alpha?: string }>().props
5+
6+
return alpha
7+
}
8+
9+
const Beta = () => {
10+
const { beta } = usePage<{ beta?: string }>().props
11+
12+
return beta
13+
}
14+
15+
export default () => {
16+
return (
17+
<>
18+
<Deferred data="alpha" fallback={<div>Loading alpha...</div>}>
19+
<Alpha />
20+
</Deferred>
21+
22+
<Deferred data="beta" fallback={<div>Loading beta...</div>}>
23+
<Beta />
24+
</Deferred>
25+
</>
26+
)
27+
}

packages/react/test-app/Pages/FormComponent/Elements.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
import { QueryStringArrayFormatOption } from '@inertiajs/core'
2-
import { Form } from '@inertiajs/react'
2+
import { config, Form } from '@inertiajs/react'
3+
4+
export default ({
5+
queryStringArrayFormat,
6+
}: {
7+
queryStringArrayFormat: QueryStringArrayFormatOption | 'force-brackets'
8+
}) => {
9+
const format: QueryStringArrayFormatOption =
10+
queryStringArrayFormat === 'force-brackets' ? 'brackets' : queryStringArrayFormat
11+
12+
if (queryStringArrayFormat === 'force-brackets') {
13+
config.set('form.forceIndicesArrayFormatInFormData', false)
14+
}
315

4-
export default ({ queryStringArrayFormat }: { queryStringArrayFormat: QueryStringArrayFormatOption }) => {
516
return (
6-
<Form action="/dump/post" method="post" queryStringArrayFormat={queryStringArrayFormat}>
17+
<Form action="/dump/post" method="post" queryStringArrayFormat={format}>
718
{({ isDirty }) => (
819
<>
920
<h1>Form Elements</h1>

0 commit comments

Comments
 (0)