Skip to content

Conversation

@laggron42
Copy link
Contributor

Summary

This adds insert_item_at for all classes which have a add_item method: BaseView, View, LayoutView, Container and ActionRow. The method follows the prototype of list.insert and allows placing items at any position, instead of defaulting to the end of the children list.

This includes some code duplication, please signal to me if you'd like some refactoring to avoid this. I prefer submitting something safe and working first, then comply with coding style.

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, ...)

@pythonmcpi
Copy link
Contributor

This feature has already been rejected by Danny. You can read the conversation in the discord.py server starting from here. Quoting a few specific messages:

When I was testing the original PR and coming up with examples I also thought that "inserting items at a specific position" would be more common than it would be but... it just wasn't
Most layout is incredibly static, and if it's dynamic then it's dynamic to a degree where the easiest thing to do is to recreate it. When you recreate a view you're better off holding off references to the objects and just re-building it
It's weird, and straight up rare, to just add something in between two items because the flow of the layout just changes completely
In fact recreating on edit just leads to cleaner code half the time anyway than doing silly tricks to modify it

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants