Giter Site home page Giter Site logo

Comments (6)

mmazzarolo avatar mmazzarolo commented on May 13, 2024

Maybe I'm missing something but isn't onModalHide enough to achieve your desired effect?
You just navigate to the previous screen when onModalHide is triggered. 🤔

Thank you for noticing the hideOnBack missing documentation, I'm adding it right now :)

from react-native-modal.

yairk avatar yairk commented on May 13, 2024

Thanks for the quick reply!

The thing is that I don't think I can tell that onModalHide was called as a result of the Back button being pressed. In my particular case, there are other triggers that can cause the modal to go away, and I want to treat the Back button differently.

from react-native-modal.

mmazzarolo avatar mmazzarolo commented on May 13, 2024

I think I got it now :)
Did you already try handling the back button press by catching it in the modal's parent component (through react-native's backandroid)?
I'm not a master of the Android back button functionality but it seems that toying a bit with it should solve your issue.

If it doesn't work I guess another solution would be making this component close when changing it's isVisible prop, but it would require a bit more code on my side... so let me know if the first solution works first! :)

from react-native-modal.

yairk avatar yairk commented on May 13, 2024

I have a listener for back button at the very "top level" of my app, and when I set hideOnBack to false my listener isn't getting called. I guess that react-native's Modal swallows the notification somehow. I actually didn't try installing a handler in the modal's parent component. Will give it a try.

Not sure I follow what you meant by closing when changing isVisible, but would it be possible for react-native-modal to expose a callback from closeOnBack (or maybe provide an argument to the onModalHide callback that indicates wasClosedByBack)? I don't think this should require too much code. I can try it tomorrow and send it as a pull request if it makes sense to you.

from react-native-modal.

mmazzarolo avatar mmazzarolo commented on May 13, 2024

Honestly, I wanted to preserve closeOnBack/onRequestClose to the current status for another nifty future I planned (hiding modal on backdrop press) but in the end add a callback shouldn't interfere too much at all so... sure, you can do it, a PR is very much welcome :)

Thanks!

from react-native-modal.

mmazzarolo avatar mmazzarolo commented on May 13, 2024

Released on v2.2.0, closing!

from react-native-modal.

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.