Skip to content
This repository has been archived by the owner on Sep 13, 2020. It is now read-only.

Menu Position Right RTL #305

Open
yogevlahyani opened this issue Jul 26, 2017 · 12 comments · May be fixed by #373
Open

Menu Position Right RTL #305

yogevlahyani opened this issue Jul 26, 2017 · 12 comments · May be fixed by #373

Comments

@yogevlahyani
Copy link

Hi, I have a RTL app and when I use menu position = right the menu has margin from the right and doesn't work like it works when its on the left position

@iddan
Copy link

iddan commented Nov 15, 2017

This should be changed to:

get boundryStyle() {
    const { menuPosition } = this.props
    if (I18nManager.isRTL && menuPosition === 'right') {
      return { right: this.state.width - this.state.openMenuOffset }
    }
    if (menuPosition === 'right' || I18nManager.isRTL && menuPosition === 'left') {
      return { left: this.state.width - this.state.openMenuOffset }
    }
    return { right: this.state.width - this.state.openMenuOffset }
  }

@gentlee
Copy link

gentlee commented Feb 11, 2018

any solution?

@gentlee
Copy link

gentlee commented Feb 11, 2018

Ok, this is my solution that has no offset at all (menu width === container width):

import SideMenu from 'react-native-side-menu';
import sideMenuStyles from 'react-native-side-menu/build/styles';

SideMenu.prototype.render = function render() {
    const menu = (
        <View style={sideMenuStyles.menu}>
            {this.props.menu}
        </View>
    );

    return (
        <View
            style={sideMenuStyles.container}
            onLayout={this.onLayoutChange}>
            {menu}
            {this.getContentView()}
        </View>
    );
}

@colmbrady
Copy link

The issue with @gentlee solution is that is will make the menu container grow to 100% of the width of page, and it will be partly covered by the drawer when opened. This means that some UI elements, e.g. buttons etc could be covered by the drawer.

The thing that confused me initially, is that 'left' and 'right' in this component have not real relation to RTL in React Native, so when you are in RTL mode, styles are flipped and things kind of go bad. If you are in RTL mode.

@iddan method of fixing this is probably closer to what is needed (Ive not tested that). Ive fixed it by doing:

const boundryStyle = { start: 0, end: (this.state.width - this.state.openMenuOffset) };

But note, that I only position the menu on the right when using RTL mode, so this seems to work for me. It probably wont work when you in LTR mode, and set drawer to 'right;

@colmbrady
Copy link

There is a fork of this library with the RTL issues addressed.
https://github.com/orionhealth/react-native-side-menu

@azizghuloum
Copy link

Another proposed fix for the issue is here:

https://github.com/azizghuloum/react-native-side-menu

@iddan
Copy link

iddan commented Jan 29, 2019

You should probably open a PR

@azizghuloum
Copy link

#373

@azizghuloum azizghuloum linked a pull request Feb 5, 2019 that will close this issue
@crcommons
Copy link

@colmbrady Any idea when #373 will be merged?

@colmbrady
Copy link

@crcommons Im not sure. I think this project is dead as no P.Rs have been merged for a longtime. Best find an alternative fork that is willing to maintain this and support RTL.

The fork I am using has deviated considerably from this project and I would not advise trying to use it.

@danleveille
Copy link

Anyone have an update fork that fixes this issue?

@colmb
Copy link

colmb commented May 3, 2020

You can get this library to behave the same: https://software-mansion.github.io/react-native-gesture-handler/docs/component-drawer-layout.html, and on Android there is also the native drawer, https://reactnative.dev/docs/drawerlayoutandroid

This library is probably not the best choice.

There is a fork of it here that I made, https://github.com/orionhealth/react-native-side-menu. It changes the implementation to support a double drawer (by nesting the component inside itself) without triggering a re-render of the entire react tree, which was more apparent on web then native, because it was triggering a reload of my entire app. There is also probably some other customisation that may be specific to the usecases we had.

I dont recommend using this ahead of the other implementations though, but if you wanted to fork it yourself and maintain your own fork, be my guest.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants