Skip to content

Commit

Permalink
fix(pagination): add pageSizeInputDisabled prop to Pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
tw15egan committed May 12, 2020
1 parent 46d64cc commit e2a4f5d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/react/src/components/Pagination/Pagination-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const props = () => ({
page: number('The current page (page)', 1),
totalItems: number('Total number of items (totalItems)', 103),
pagesUnknown: boolean('Total number of items unknown (pagesUnknown)', false),
pageSizeInputDisabled: boolean(
'Disable page size input (pageInputDisabled)',
false
),
pageInputDisabled: boolean('Disable page input (pageInputDisabled)', false),
backwardText: text(
'The description for the backward icon (backwardText)',
Expand Down
13 changes: 12 additions & 1 deletion packages/react/src/components/Pagination/Pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ export default class Pagination extends Component {
* `true` if the select box to change the page should be disabled.
*/
pageInputDisabled: PropTypes.bool,

/**
* `true` if the select box to change the page size should be disabled.
*/
pageSizeInputDisabled: PropTypes.bool,
};

static defaultProps = {
Expand All @@ -141,6 +146,7 @@ export default class Pagination extends Component {
pagesUnknown: false,
isLastPage: false,
pageInputDisabled: false,
pageSizeInputDisabled: false,
itemText: (min, max) => `${min}${max} items`,
pageText: page => `page ${page}`,
};
Expand Down Expand Up @@ -188,7 +194,10 @@ export default class Pagination extends Component {
Math.max(Math.ceil(this.props.totalItems / this.state.pageSize), 1)
) {
this.setState({ page });
this.props.onChange({ page, pageSize: this.state.pageSize });
this.props.onChange({
page,
pageSize: this.state.pageSize,
});
}
};

Expand Down Expand Up @@ -233,6 +242,7 @@ export default class Pagination extends Component {
pagesUnknown,
isLastPage,
pageInputDisabled,
pageSizeInputDisabled,
totalItems,
onChange, // eslint-disable-line no-unused-vars
page: pageNumber, // eslint-disable-line no-unused-vars
Expand Down Expand Up @@ -278,6 +288,7 @@ export default class Pagination extends Component {
noLabel
inline
onChange={this.handleSizeChange}
disabled={pageSizeInputDisabled}
value={statePageSize}>
{pageSizes.map(size => (
<SelectItem key={size} value={size} text={String(size)} />
Expand Down

0 comments on commit e2a4f5d

Please sign in to comment.