Coder Social home page Coder Social logo

popup bar and popup content can get stuck in wrong position when dismissing a modal sheet with the keyboard in a transitory state about lnpopupui HOT 20 CLOSED

leonatan avatar leonatan commented on July 18, 2024
popup bar and popup content can get stuck in wrong position when dismissing a modal sheet with the keyboard in a transitory state

from lnpopupui.

Comments (20)

LeoNatan avatar LeoNatan commented on July 18, 2024

Hmm, wow, never seen that. Need to check if this is a SwiftUI layout bug, or my underlying framework is buggy. Will look soon.

from lnpopupui.

LeoNatan avatar LeoNatan commented on July 18, 2024

BTW, this isn’t supposed to happen. The popup bar is supposed to remain glued to the tab bar. What OS is this?

from lnpopupui.

svenoaks avatar svenoaks commented on July 18, 2024

It's iOS 14.7.1. I'll see if it's something I'm doing in the app to make it unglued.

Here's another video that's a worse case where it gets stuck completely.

keyboard2.mp4

from lnpopupui.

svenoaks avatar svenoaks commented on July 18, 2024

Ok it seems .popupBarCustomView is what causes the bar to be unglued from the tab bar, if I don't use it, it stays glued. However, the worse bug still happens. I'll see if I can make a small test project where it can be reproduced.

from lnpopupui.

LeoNatan avatar LeoNatan commented on July 18, 2024

Yes, please. That would be helpful.

from lnpopupui.

svenoaks avatar svenoaks commented on July 18, 2024

Hi, test project here can repo it easily: https://github.com/svenoaks/testPopupUI

Easier to use two hands.

For demo1.mp4 I click on the TextField then rapidly swipe down the sheet to dismiss with other hand.
For demo2.mp4 I click on the TextField then jam the CLOSE button with other hand.

It's only happening when the keyboard is in some kind of transitory state.

If I get rid of .popupBarCustomView, I can't seem to make demo1 happen, but demo2 still does.

demo1.mp4
demo2.mp4

from lnpopupui.

LeoNatan avatar LeoNatan commented on July 18, 2024

This seems like a bug in SwiftUI. It is hellbent on providing the incorrect layout size for the custom popup bar view. There is no issue that I could see with a standard bar (because it is all UIKit). I've implemented a nasty hack that basically ignores popup bar size changes when the keyboard is open, and when it gets closed, it updates the size in case an actual size update is necessary. I think this is a relatively safe hack, as the custom popup bar view would normally change size only after user interaction.

from lnpopupui.

LeoNatan avatar LeoNatan commented on July 18, 2024

Please try 1.2.17. Thanks

from lnpopupui.

svenoaks avatar svenoaks commented on July 18, 2024

The one from demo1.mp4 is fixed in 1.2.17 but demo2 still happens. You have to use the Close button. It can happen with or without the custom popup bar. I updated the demo project without the custom bar, and here's a video of it happening without the custom popup bar.

demo3.mp4

from lnpopupui.

LeoNatan avatar LeoNatan commented on July 18, 2024

Interesting. Will look into it again.

from lnpopupui.

LeoNatan avatar LeoNatan commented on July 18, 2024

Interesting, it doesn't reproduce on iOS 15. That's good. I will see what hacks are necessary on iOS 14 to resolve this.

from lnpopupui.

LeoNatan avatar LeoNatan commented on July 18, 2024

Sorry, unable to reproduce.

Simulator.Screen.Recording.-.iPhone.8.Plus.-.2021-09-10.at.02.03.00.mp4
Simulator.Screen.Recording.-.iPhone.8.Plus.-.2021-09-10.at.02.01.24.mp4

from lnpopupui.

svenoaks avatar svenoaks commented on July 18, 2024

I tap on the TextFIeld with one hand, then immediately tap Close with the other hand, there's gotta be very little delay.

from lnpopupui.

LeoNatan avatar LeoNatan commented on July 18, 2024

Not reproducing:

RPReplay_Final1631229363.MP4

Please find a consistent way to reproduce this issue.

from lnpopupui.

svenoaks avatar svenoaks commented on July 18, 2024

try latest commit, it automates causing it two seconds after tapping on DOCUMENT PICKER button. I tried it on the iPhone 12 Pro Max Simulator iOS 14.5 (make sure the soft keyboard is coming out in Messages first, it's I/O...Keyboard...Toggle Soft Keyboard, but I think you have to click this when a TextField is focused), and iPhone 6s with iOS 14.7.1.

Not happening on iPad Pro, but SwiftUI uses a different component for .sheet there, so that might have something to do with it.

Not just an academic problem, I caused this a few times accidentally before I figured out where it was coming from.

from lnpopupui.

LeoNatan avatar LeoNatan commented on July 18, 2024

Your commit reproduced the issue, thanks. Investigating.

from lnpopupui.

LeoNatan avatar LeoNatan commented on July 18, 2024

You know, I'm not even sure this is a bug with the popup. It seems like resigning the first responder too quickly breaks the internal layout handling for safe areas. Even without any popup, notice how your tab view looks:

Simulator Screen Shot - iPhone 12 Pro Max - 2021-09-10 at 03 31 01

On iOS 15, this is fixed:

Simulator Screen Shot - iPhone 12 Pro Max - 2021-09-10 at 03 33 37

Likewise, your issue doesn't occur there:

Simulator.Screen.Recording.-.iPhone.12.Pro.Max.-.2021-09-10.at.03.34.34.mp4

I'm not sure what more I can do here. It seems SwiftUI layout is broken on iOS 14.

from lnpopupui.

svenoaks avatar svenoaks commented on July 18, 2024

Good find, it's a SwiftUI bug and glad to see fixed in iOS15.

from lnpopupui.

LeoNatan avatar LeoNatan commented on July 18, 2024

Screen Shot 2021-09-10 at 05 55 36

So, if I do this hack, it fixes the issues. πŸ™ˆ The problem comes from bad state management inside SwiftUI, where if the keyboard will hide notification is sent too early (~5 runloop spins), SwiftUI layout breaks.

Unfortunately, I don't feel comfortable adding this hack into LNPopupUI. If you'd like to add it, you can just register some object to listen to UIApplication.keyboardWillHideNotification and repost the notification again, after 5 runloop spins. You can maybe only run it if iOS 14 and below.

from lnpopupui.

svenoaks avatar svenoaks commented on July 18, 2024

Thanks for that

from lnpopupui.

Related Issues (20)

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.