Skip to content

Pagination#canAdvance and Pagination#canBack always trueΒ #682

Open
@nicolube

Description

@nicolube

Is there an existing issue for this?

  • I have searched the existing issues

πŸ› Describe the bug

Hello I have an Kotlin extension function looking like this:

    @JvmStatic
    fun RenderContext.pagination(state: State<Pagination>, fallBack: ViewItems = ViewItems.MENU_PLACEHOLDER) {

        "NP".forEach { layoutSlot(it, fallBack.get()) }

        layoutSlot('N', ViewItems.NEXT_PAGE.get()).displayIf { c -> state.get(c).canAdvance() }
            .updateOnStateChange(state)
            .onClick { context ->
                val pagination = state.get(context)
                pagination.advance()
                CustomSounds.MENU_CLICK.playSound(this.player)
            }
        layoutSlot('P').displayIf { c -> state.get(c).canBack() }
            .updateOnStateChange(state)
            .onClick { context ->
                val pagination = state.get(context)
                pagination.back()
                CustomSounds.MENU_CLICK.playSound(this.player)
            }
    }

It adds next and Previous buttons to a layout, my issue is here that they are always added, no matter of there is just 1 or 50 Items in the Pennington.

This Problem only exists with all computedPagintons

βœ”οΈ Expected behavior

Well, that the items are not displayed if there is no next or previous site.

πŸ‘£ Steps to Reproduce

No response

πŸ’» Platform

  • Bukkit
  • Sponge
  • Other

⭐ Server Version

Paper version 1.21.1-122-master@4430e96 (2024-10-12T21:18:42Z) (Implementing API version 1.21.1-R0.1-SNAPSHOT)

πŸ“š Library Version

3.0.11

✍️ Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions