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

element.delete() does not correctly delete an element #1512

Closed
3 tasks done
falkoschindler opened this issue Aug 29, 2023 · 2 comments · Fixed by #1514
Closed
3 tasks done

element.delete() does not correctly delete an element #1512

falkoschindler opened this issue Aug 29, 2023 · 2 comments · Fixed by #1514
Assignees
Labels
bug Something isn't working
Milestone

Comments

@falkoschindler
Copy link
Contributor

falkoschindler commented Aug 29, 2023

Description

Noted by @dreusel on Discord and in #1500, the delete() method does not actually delete an element. It is merely used internally and can be overwritten to register some cleanup procedure, like e.g. here in ui.scene:
https://github.com/zauberzeug/nicegui/blob/main/nicegui/elements/scene.py#L187-L189

But instead of simply renaming it into _delete(), we should also think about a method for removing a single element, which could be delete(). In contrast to clear() (remove all children) and remove() (remove a single child) it could be called to remove the element itself.

So I propose the following:

  • rename delete() to _on_delete()
  • introduce a new delete() that removes a single element from the UI
  • add (or extend) a section in the documentation explaining clear(), remove(), delete() and maybe _on_delete()
@falkoschindler
Copy link
Contributor Author

Actually the title is incorrect: element.delete() does delete an element. But it is currently not the intended way, because it doesn't delete children and bindings.

@falkoschindler falkoschindler changed the title element.delete() does not delete an element element.delete() does not correctly delete an element Aug 29, 2023
@falkoschindler
Copy link
Contributor Author

I started to work on the draft PR #1514.

@falkoschindler falkoschindler linked a pull request Aug 29, 2023 that will close this issue
4 tasks
@falkoschindler falkoschindler added this to the 1.3.13 milestone Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant