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

Pagination: should support disabled prop #3275

Closed
kamilml opened this issue Nov 12, 2018 · 3 comments
Closed

Pagination: should support disabled prop #3275

kamilml opened this issue Nov 12, 2018 · 3 comments

Comments

@kamilml
Copy link

kamilml commented Nov 12, 2018

I think a disabled option for Pagination would be very helpful.

Sorry but the request is very simple. No more words :)

@welcome
Copy link

welcome bot commented Nov 12, 2018

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you've completed all the fields in the issue template so we can best help.

We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

@takerukoushirou
Copy link

Recently I also needed to disable pagination and the solution I came up with was to explicitly set the disabled prop for all item types. As a side effect, it also adds more flexibility to e.g. disable next/last, if the last page is active, and first/previous, if the first page is active.

// Disable all pagination items on page change.
const paginationProps: PaginationProps = {
    totalPages: totalPages,
    activePage: activePage,
    onPageChange: this.handlePageChange,

    // Each item is based on the default props, in case they may change in the future.
    // defaultProps is not contained in the @types definition, hence the cast to any.
    pageItem: {
        ...(Pagination as any).defaultProps.pageItem,
        disabled: pageChanging,
    },
    nextItem: {
        ...(Pagination as any).defaultProps.nextItem,
        disabled: pageChanging || (activePage >= totalPages),
        icon: true,
        content: <Icon name="angle right" />,
    },
    lastItem: {
        ...(Pagination as any).defaultProps.lastItem,
        disabled: pageChanging || (activePage === totalPages),
        icon: true,
        content: <Icon name="angle double right" />,
    },
    prevItem: {
        ...(Pagination as any).defaultProps.prevItem,
        disabled: pageChanging || (activePage <= 1),
        icon: true,
        content: <Icon name="angle left" />,
    },
    firstItem: {
        ...(Pagination as any).defaultProps.firstItem,
        disabled: pageChanging || (activePage === 1),
        icon: true,
        content: <Icon name="angle double left" />,
    },
    ellipsisItem: {
        icon: true,
        content: <Icon name="ellipsis horizontal" />,
    },
};

To just quickly disable all items though I'm also in favour of having a convenient disabled prop for Pagination itself.

@layershifter layershifter changed the title Disabled for Pagination Pagination: should support disabled prop Nov 19, 2018
@layershifter
Copy link
Member

A very nice feature 👍 We definitely should implement it.

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

No branches or pull requests

3 participants