Skip to content

Button Behaviour Inconsitency when using rows parameter #2944

@tibue99

Description

@tibue99

Summary

Buttons change behaviour when the same view is used multiple times

Reproduction Steps

  1. Run the code
  2. Click the buttons in the second response

Minimal Reproducible Code

import discord

bot = discord.Bot(intents=discord.Intents.default())


@bot.slash_command()
async def greet(ctx):
    await ctx.respond(view=TestView(), ephemeral=True)
    await ctx.respond(view=TestView(), ephemeral=True)


class TestView(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=None)

    @discord.ui.button(label="Row 2", row=2)
    async def button_callback2(self, button, interaction):
        await interaction.respond("Row 2", ephemeral=True)

    @discord.ui.button(label="No Row")
    async def button_callback3(self, button, interaction):
        await interaction.respond("No Row", ephemeral=True)


bot.run("")

Expected Results

The buttons should respond like in the first message.

Actual Results

The buttons swap their behaviour, but they are visually aligned like in the first message.

Intents

discord.Intents.default

System Information

  • Python v3.13.3-final
  • py-cord v2.7.None-candidate
    • py-cord importlib.metadata: v2.7.0rc2.dev67+gd5d162ac5
  • aiohttp v3.12.15
  • system info: Windows 11 10.0.26100

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

The buttons in first message work as expected, but when the view is used the second time, the buttons show the wrong output
Image

  • When switching the order of callbacks, it fixes this scenario
  • Passing row=1 to the top button also fixes the issue here

Metadata

Metadata

Assignees

No one assigned

    Labels

    unconfirmed bugA bug report that needs triaging

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions