Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lit-form): initialize api before adding controller #1254

Merged
merged 3 commits into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Defined in: [tanstack-form-controller.ts:206](https://github.com/TanStack/form/b
field<TName, TData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync>(fieldConfig, render): object
```

Defined in: [tanstack-form-controller.ts:260](https://github.com/TanStack/form/blob/main/packages/lit-form/src/tanstack-form-controller.ts#L260)
Defined in: [tanstack-form-controller.ts:259](https://github.com/TanStack/form/blob/main/packages/lit-form/src/tanstack-form-controller.ts#L259)

#### Type Parameters

Expand Down Expand Up @@ -145,7 +145,7 @@ render: renderCallback<TParentData, TName, TData, TOnMount, TOnChange, TOnChange
hostConnected(): void
```

Defined in: [tanstack-form-controller.ts:250](https://github.com/TanStack/form/blob/main/packages/lit-form/src/tanstack-form-controller.ts#L250)
Defined in: [tanstack-form-controller.ts:249](https://github.com/TanStack/form/blob/main/packages/lit-form/src/tanstack-form-controller.ts#L249)

Called when the host is connected to the component tree. For custom
element hosts, this corresponds to the `connectedCallback()` lifecycle,
Expand All @@ -169,7 +169,7 @@ ReactiveController.hostConnected
hostDisconnected(): void
```

Defined in: [tanstack-form-controller.ts:256](https://github.com/TanStack/form/blob/main/packages/lit-form/src/tanstack-form-controller.ts#L256)
Defined in: [tanstack-form-controller.ts:255](https://github.com/TanStack/form/blob/main/packages/lit-form/src/tanstack-form-controller.ts#L255)

Called when the host is disconnected from the component tree. For custom
element hosts, this corresponds to the `disconnectedCallback()` lifecycle,
Expand Down
3 changes: 1 addition & 2 deletions packages/lit-form/src/tanstack-form-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,6 @@ export class TanStackFormController<
TSubmitMeta
>,
) {
;(this.#host = host).addController(this)

this.api = new FormApi<
TParentData,
TFormOnMount,
Expand All @@ -245,6 +243,7 @@ export class TanStackFormController<
TFormOnServer,
TSubmitMeta
>(config)
;(this.#host = host).addController(this)
}

hostConnected() {
Expand Down