Giter VIP home page Giter VIP logo

mapoptionalios14bug's Introduction

I've filed a bug with Apple: FB8196917

Steps to Reproduce

Create a List of Object with a onTapGesture that sets a @State var tappedObject: Object? variable. In the .sheet() map on that object and present it it's not nil.

struct Object: Identifiable {
    var id: String
}

struct ContentView: View {
    @State var objects = [
        Object(id: "1"),
        Object(id: "2"),
        Object(id: "3"),
        Object(id: "4"),
        Object(id: "5")
    ]
    @State var tappedObject: Object?
    @State var showSheet = false
                
    var body: some View {
        List {
            ForEach(objects) { object in
                Text(object.id)
                    .onTapGesture {
                        self.tappedObject = object
                        self.showSheet = true
                    }
            }
            .sheet(isPresented: self.$showSheet) {
                self.tappedObject.map {
                    Text($0.id)
                }
            }
        }
    }
}

Run the app and tap on any row.

Expected:

  • It will present a sheet that will show that object's ID.

Actual:

  • It works properly on iOS 13
  • On iOS 14, the first tap you tap an object, the sheet is completly empty. Sometimes the first few times you try it, it doesn't work and then it eventually starts working. In the screen recording, the first two tries did not work and the third try did.

I've seen others mention this bug on the Apple forms and a Developer Tools Engineer suggested filing a Feedback: https://developer.apple.com/forums/thread/650818

Workarounds

I've switched to the sheet(item:onDismiss:content:) API which works properly with optional state objects.

mapoptionalios14bug's People

Watchers

Jeremy Gale avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.