microsoft / react-native-macos

A framework for building native macOS apps with React.
https://microsoft.github.io/react-native-windows/
MIT License
3.49k stars 135 forks source link

fix: Properly dismiss RCTDevLoadingView #2211

Closed Saadnajmi closed 4 days ago

Saadnajmi commented 4 days ago

Summary:

This is attempt #2 to fix issues with the refactor of RCTDevLoadingView , the first being #2201 . Namely, the RCTDevLoadingView sheet doesn't always dismiss, and sticks around blocking the app.

This PR addresses two main things:

  1. React Native seems to not balance its' own calls to [RCTDevLoadingView showMessage] and [RCTDevLoadingView hide]. As a result, we might end up calling beginSheet more times than we call endSheet. My theory is we're ending up with multiple sheets/modals, which is why the sheet is sticking around. We can fix this by only calling beginSheet if we aren't already presented.

  2. Digging around a couple of places in StackOverflow, it seems it's also important to call [mySheetWindow orderOut:] I the beginSheet completion handler to make the sheet go away. In my testing, this seems to be true.

While we're here, let's fix a couple of nits:

  1. Release the sheet window when closed. I don't think there's any benefit keeping it around, especially if we're already nilling it out in hide.
  2. Set the font of the label to be the same as iOS.

Test Plan:

Launching the app a bunch of times (sometimes with breakpoints set to interrupt the flow), I seem to not have the sheet stick around. Of course this is intermittent, so it's not a definitive test.