I am trying to add a close button to the modally presented View\'s navigation bar. However, after dismiss, my view models deinit method is never called. I\'
My solution is
.navigationBarItems( trailing: self.filterButton ) .......................................... var filterButton: some View { Button(action: {[weak viewModel] in viewModel?.showFilter() },label: { Image("search-filter-icon").renderingMode(.original) }) }