Customizing Alert Configuration in Nested Views
func configureCustomAlert(configure: (inout CustomAlertConfiguration) -> Void) -> some View { environment(\.customAlertConfiguration, .create(configure: configure)) }
This allows me to customize the alert configuration, and I can set a global configuration in my AppDelegate like this:
.environment(\.customAlertConfiguration, .create { config in config.background = .color(.red) })
However, when I attempt to customize an alert configuration in an inner view—for example, to only modify the “dismiss on tap” behavior—it resets the entire configuration to its default values. This causes the previous global configuration (e.g., config.background = .color(.red)) to be lost, and the alert uses default settings instead of inheriting the existing configuration.
Expected Behavior
When customizing the alert configuration in an inner view, it should retrieve the existing settings (such as the globally configured background color) and only apply the new customizations (e.g., disabling “dismiss on tap”). The configuration passed to the inner view should inherit and build upon the global configuration rather than resetting it.
Customizing Alert Configuration in Nested Views
func configureCustomAlert(configure: (inout CustomAlertConfiguration) -> Void) -> some View { environment(\.customAlertConfiguration, .create(configure: configure)) }
This allows me to customize the alert configuration, and I can set a global configuration in my AppDelegate like this:.environment(\.customAlertConfiguration, .create { config in config.background = .color(.red) })
However, when I attempt to customize an alert configuration in an inner view—for example, to only modify the “dismiss on tap” behavior—it resets the entire configuration to its default values. This causes the previous global configuration (e.g., config.background = .color(.red)) to be lost, and the alert uses default settings instead of inheriting the existing configuration.
Expected Behavior When customizing the alert configuration in an inner view, it should retrieve the existing settings (such as the globally configured background color) and only apply the new customizations (e.g., disabling “dismiss on tap”). The configuration passed to the inner view should inherit and build upon the global configuration rather than resetting it.