Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making default theme RTL won't apply to some components #3348

Closed
mohas opened this issue Jun 19, 2019 · 5 comments
Closed

Making default theme RTL won't apply to some components #3348

mohas opened this issue Jun 19, 2019 · 5 comments
Labels

Comments

@mohas
Copy link

mohas commented Jun 19, 2019

What you were expecting:
for all the components to flip when I specify RTL in theme and dir="rtl" on body tag

What happened instead:
setting rtl on theme does absolutely nothing.
ra-rtl
As you can see many components are not RTL, icons are not flipped, paddings are not flipped, there is text-align: left; defined on the body.
I made list and edit components rtl using a jssProvider like:

const jss = create({ plugins: [...jssPreset().plugins, rtl()] });

function RTL(props) {
  return (
    <JssProvider jss={jss}>
      {props.children}
    </JssProvider>
  );
}

Then use it with list and edit and create components:

<RTL>
  <List {...props} ...

Steps to reproduce:

1-Create an RTL theme:

const theme = {
  direction: 'rtl',
  typography: {
    fontFamily: 'IranSans'
  },
  isRtl: true
};
const themeWithDirection = createMuiTheme({...defaultTheme, ...theme});

2-Pass it to Admin component:

<Admin locale="fa" i18nProvider={i18nProvider} theme={theme} ...

There is very little badly written documentation and answers regarding these issues, so any help is appreciated, thanks.

Environment

  • React-admin version: 2.9.3
  • React version: 16.6.3
  • Browser: any
@mohas
Copy link
Author

mohas commented Jun 20, 2019

I've made further inspections on next, back buttons and why their icons won't flip, turns out material-ui TablePaginationActions is doing a correct job regarding theme direction:

return _react.default.createElement("div", other, _react.default.createElement(_IconButton.default, (0, _extends2.default)({
        onClick: this.handleBackButtonClick,
        disabled: page === 0
      }, backIconButtonProps), theme.direction === 'rtl' ? _ref : _ref2), _react.default.createElement(_IconButton.default, (0, _extends2.default)({
        onClick: this.handleNextButtonClick,
        disabled: page >= Math.ceil(count / rowsPerPage) - 1
      }, nextIconButtonProps), theme.direction === 'rtl' ? _ref3 : _ref4));

but PaginationActions in react-admin does not regard theme direction when making action buttons, so my guess is the same problem lies everywhere in react-admin components so how can I introduce theme prop into those components?

@mohas
Copy link
Author

mohas commented Jun 20, 2019

I made a gist to show how to fix it, can I make this into a pull request?
PaginationActions

@djhi
Copy link
Collaborator

djhi commented Jun 20, 2019

Hi, thanks for reporting the issue. It's very difficult to spot any changes in a gist. Please open a pull request and we'll do our best to review it and iterate with you.

@fzaninotto fzaninotto added the bug label Jun 20, 2019
@fzaninotto
Copy link
Member

Thanks for the bug report. Please note that we don't have the need or the ability to test admins with RTL turned on. We'll need help from the community to fix that one, so PRs are welcome.

@jdemangeon
Copy link
Contributor

Fixed by #4496

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

No branches or pull requests

4 participants