Skip to content

Commit

Permalink
Merge pull request #4496 from alikazemkhanloo/patch-2
Browse files Browse the repository at this point in the history
Fix pagination buttons are in the wrong direction in RTL languages
  • Loading branch information
fzaninotto committed Mar 10, 2020
2 parents 697e037 + 2641e12 commit bb82919
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/ra-ui-materialui/src/list/PaginationActions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import Button from '@material-ui/core/Button';
import { makeStyles } from '@material-ui/core/styles';
import { makeStyles, useTheme } from '@material-ui/core/styles';
import ChevronLeft from '@material-ui/icons/ChevronLeft';
import ChevronRight from '@material-ui/icons/ChevronRight';
import { useTranslate } from 'ra-core';
Expand All @@ -22,6 +22,7 @@ function PaginationActions(props) {
const { page, rowsPerPage, count, onChangePage, color, size } = props;
const classes = useStyles(props);
const translate = useTranslate();
const theme = useTheme();
/**
* Warning: material-ui's page is 0-based
*/
Expand Down Expand Up @@ -126,7 +127,11 @@ function PaginationActions(props) {
onClick={prevPage}
className="previous-page"
>
<ChevronLeft />
{theme.direction === 'rtl' ? (
<ChevronRight />
) : (
<ChevronLeft />
)}
{translate('ra.navigation.prev')}
</Button>
)}
Expand All @@ -140,7 +145,11 @@ function PaginationActions(props) {
className="next-page"
>
{translate('ra.navigation.next')}
<ChevronRight />
{theme.direction === 'rtl' ? (
<ChevronLeft />
) : (
<ChevronRight />
)}
</Button>
)}
</div>
Expand All @@ -163,6 +172,7 @@ PaginationActions.propTypes = {
rowsPerPage: PropTypes.number.isRequired,
color: PropTypes.oneOf(['primary', 'secondary']),
size: PropTypes.oneOf(['small', 'medium', 'large']),
theme: PropTypes.object,
};

PaginationActions.defaultProps = {
Expand Down

0 comments on commit bb82919

Please sign in to comment.