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

A self-removed widget can leave the layout unfinished #2016

Closed
davep opened this issue Mar 10, 2023 · 5 comments
Closed

A self-removed widget can leave the layout unfinished #2016

davep opened this issue Mar 10, 2023 · 5 comments
Labels
bug Something isn't working Task

Comments

@davep
Copy link
Contributor

davep commented Mar 10, 2023

Using the following code, with 0.14.0, hit the a button a few times to add some buttons. Next, navigate to a button somewhere in the middle of the stack and press it. This will remove the button but not refresh the layout correctly. I'm finding that in some situations it'll leave a hole where the button was, and then refresh properly on the next full interaction; other times it'll leave a "ghost" version of the button in place under some interaction takes place.

from textual.app        import App, ComposeResult
from textual.containers import Vertical
from textual.widgets    import Header, Footer, Button

class SelfRemoveButton( Button ):

    DEFAULT_CSS = """
    SelfRemoveButton {
        width: 100%;
    }
    """

    def on_button_pressed( self ):
        self.remove()

class SelfRemoveApp( App[ None ] ):

    BINDINGS = [
        ( "a", "add", "Add a button" )
    ]

    def compose( self ) -> ComposeResult:
        yield Header()
        yield Vertical()
        yield Footer()

    def action_add( self ) -> None:
        self.query_one( Vertical ).mount( SelfRemoveButton( "Press me to remove me" ) )

if __name__ == "__main__":
    SelfRemoveApp().run()
@davep
Copy link
Contributor Author

davep commented Mar 10, 2023

Now I think about it, I suspect this is a duplicate of #2007 -- I'll test with main in a moment (was testing with 0.14)

@davep
Copy link
Contributor Author

davep commented Mar 10, 2023

Nope, not a dupe. Still happens with main.

@Ayehavgunne
Copy link

I am seeing this as well when I add a class with display: none;

@willmcgugan
Copy link
Collaborator

Can't reproduce in current main. Assuming fixed.

@github-actions
Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Task
Projects
None yet
Development

No branches or pull requests

3 participants