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

Fix pagination buttons are in the wrong direction in RTL languages #4496

Merged
merged 3 commits into from
Mar 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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