Skip to content

Add new usage specific initializers for AttachmentsFeatureElementView#1165

Merged
dfeinzimer merged 1 commit intoFeatureFormView/UtilityNetworkAssociationFormElementfrom
df/1160.followup
May 20, 2025
Merged

Add new usage specific initializers for AttachmentsFeatureElementView#1165
dfeinzimer merged 1 commit intoFeatureFormView/UtilityNetworkAssociationFormElementfrom
df/1160.followup

Conversation

@dfeinzimer
Copy link
Collaborator

This resolves a crash introduced in #1160 by ensuring that an InternalFeatureFormViewModel is present when needed.

Unlike with an ObservableObject, if an @Observable object is not in the environment, such as is the case when using AttachmentsFeatureElementView in a popup, a fatal error is encountered:

SwiftUICore/Environment+Objects.swift:34: Fatal error: No Observable object of type InternalFeatureFormViewModel found. A View.environmentObject(_:) for InternalFeatureFormViewModel may be missing as an ancestor of this view.

Note that FormViewModel was renamed to InternalFeatureFormViewModel after #1160 in #1162.

Thank you to @CalebRas for catching this new crash.

@dfeinzimer dfeinzimer requested review from CalebRas and mhdostal May 20, 2025 19:03
@dfeinzimer dfeinzimer self-assigned this May 20, 2025
Copy link
Collaborator

@CalebRas CalebRas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for fixing this!

@dfeinzimer dfeinzimer merged commit d252c5c into FeatureFormView/UtilityNetworkAssociationFormElement May 20, 2025
@dfeinzimer dfeinzimer deleted the df/1160.followup branch May 20, 2025 22:19
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.

3 participants