Skip to content

Conversation

@janpollak
Copy link
Contributor

When NavigationStackFlow is initialized without the 'detents' parameter, it was applying .presentationDetents([]) (empty set) which incorrectly overrode presentation detents defined in child views.

This change introduces OptionalPresentationDetentsModifier that only applies presentation detents when they are explicitly provided (non-nil), allowing child views to define their own detents without interference.

Issue:

  • Child views using .presentationDetents() were being overridden
  • Sheets would open at maximum detent instead of specified heights
  • Close buttons and custom detent behaviors were broken

Solution:

  • Replace .presentationDetents(navigationDetents ?? []) with conditional modifier
  • Only apply detents when explicitly provided via init parameter
  • Preserve backward compatibility for existing code

When NavigationStackFlow is initialized without the 'detents' parameter,
it was applying .presentationDetents([]) (empty set) which incorrectly
overrode presentation detents defined in child views.

This change introduces OptionalPresentationDetentsModifier that only
applies presentation detents when they are explicitly provided (non-nil),
allowing child views to define their own detents without interference.

Issue:
- Child views using .presentationDetents() were being overridden
- Sheets would open at maximum detent instead of specified heights
- Close buttons and custom detent behaviors were broken

Solution:
- Replace .presentationDetents(navigationDetents ?? []) with conditional modifier
- Only apply detents when explicitly provided via init parameter
- Preserve backward compatibility for existing code
@janpollak janpollak requested a review from ssestak October 27, 2025 20:36
Copy link
Contributor

@ssestak ssestak left a comment

Choose a reason for hiding this comment

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

Nice catch 👍

@janpollak janpollak merged commit 8e68ee1 into main Oct 30, 2025
1 check passed
@janpollak janpollak deleted the fix/presentation-detents-override branch October 30, 2025 09:13
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.

4 participants