PasteButton is not displayed outside of the root View after a while after launching the app

SwiftUI PasteButton will not be displayed in any view other than the view at the root of the NavigationStack after about a day has passed since the app was launched.

PasteButton is visible whenever it's placed in the root view. However, PasteButton is not displayed in the view transitioned by navigationDestination of NavigationStack or in the view displayed by sheet.

Here is the complete repro code:

import SwiftUI

struct ContentView: View {
    @State var showChildView = false

    var body: some View {
        NavigationStack {
            VStack {
                TextAndPasteButton()
                Spacer()
                Button(action: {
                    showChildView = true
                }, label: {
                    Text("Go to child view")
                })
            }
            .navigationTitle("Root View")
            .navigationDestination(isPresented: $showChildView) {
                TextAndPasteButton()
                .navigationTitle("Child View")
            }
        }
    }
}

struct TextAndPasteButton: View {
    @State var text: String = "(initial text)"

    var body: some View {
        VStack {
            Text(text)

            PasteButton(payloadType: String.self) { texts in
                guard let text = texts.first else { return }
                self.text = text
            }
        }
    }
}

Screenshots:

  • Root view where PasteButton is always visible:

  • Child view where PasteButton is visible correctly:

  • Child view where PasteButton is not displayed that I'm reporting here:

Reproduction conditions are not clear; I have confirmed that the problem can occur after a period of time, such as a day, but sometimes the problem occurs within a few hours, and sometimes it takes 2-3 days for the problem to occur.

I have confirmed the problem on iPhone 14 Pro and iPhone 15 with iOS 17.2.1. Xcode version is 15.1.

Can anyone point out if I am doing something wrong? (I reported this to Apple as an iOS bug, but it's ignored..)

PasteButton is not displayed outside of the root View after a while after launching the app
 
 
Q