SteffeyDev / react-native-popover-view

A well-tested, adaptable, lightweight <Popover> component for react-native
MIT License
613 stars 92 forks source link

fix: break early when rect satisfies conditions #179

Closed AdamGerthel closed 1 month ago

AdamGerthel commented 1 month ago

Fixes #177

Based on my interpretation of the code, there would always be a 100ms delay before the do/while loop finished, even if the conditions were met on the first loop. This change breaks the loop before the delay, based on the same conditions. During my testing, every time calculateRectFromRef ran for the first time (it seems to run twice when opening a popover), the conditions were always met on the first loop. This change removes exactly 100ms of delay when opening a popover.

Tested on both Android and iOS.

AdamGerthel commented 1 month ago

This actually partially fixes #37 as well, it seems. After the change in this PR, I'm only ever able to reproduce #37 when using the native modal mode. I suspect that the additional layer of state is causing a race condition which causes the modal to sometimes end up in a state where it cannot be closed and doesn't close, despite isVisible being set to false.

SteffeyDev commented 1 month ago

Thanks!

SteffeyDev commented 1 month ago

Released as 5.0.9. Didn't test myself, looks like a small change and trusting you on that.