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

Weird focus behavior when focused item is removed #5630

Open
mzebrak opened this issue Mar 10, 2025 · 1 comment
Open

Weird focus behavior when focused item is removed #5630

mzebrak opened this issue Mar 10, 2025 · 1 comment

Comments

@mzebrak
Copy link

mzebrak commented Mar 10, 2025

While writing MRE for #5629 I noticed a strange thing with focus. When the focused element is removed, focus jumps to the last element on the screen.

Looks like that's because the previous element on the screen is being focused instead of focusing the next one.

MRE

from __future__ import annotations

from textual import on
from textual.app import App, ComposeResult
from textual.widgets import Button


class ExampleApp(App):
    def compose(self) -> ComposeResult:
        for i in range(20):
            yield Button(f"Remove {i}")

    @on(Button.Pressed)
    def remove_item(self, event: Button.Pressed) -> None:
        event.button.remove()


if __name__ == "__main__":
    ExampleApp().run()

Video:

Screencast.from.03-10-2025.09.07.21.AM.webm
Copy link

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

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

No branches or pull requests

1 participant