Modalbox doesn't centered on phone that setting with right to left language.
I have an issue with modalbox that doesn't centered. My virtual android set on right to left language such as Hebrew ,Arabic or Tamashek, and when I setup a modalbox (modal centered) with on react native app the modal windows stick to the right side of the screen, did anyone knows how to fix this issue? I need the modal in the middle of the screen like "position centered + backdrop".
Thanks
I fixed this problem by change index.js file in \node_modules\react-native-modalbox.
in renderContent() function, just add a minus at the start of defining offsetX.
actually you have to change this:
var offsetX = (this.state.containerWidth - this.state.width) / 2;
to this:
var offsetX = -(this.state.containerWidth - this.state.width) / 2;
I hope it works for you too...
@alisn72 this just shifts the bug to non-rtl layouts ;))
@igsm The question is about an RTL application! for LTR apps the original library works well... also, it is just a trick i was used before and it is not a general solution
How I fix mine was I imported I18nManager from react native then worked on the Modal style by giving it a margin to fix the offset
import { I18nManager, StyleSheet } from 'react-native'
const styles = StyleSheet.create({
modal: {
justifyContent: 'center',
alignItems: 'center',
alignSelf: 'center',
marginRight: I18nManager.isRTL ? -40 : 0
},
});