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

List items in a Markdown can receive focus #2380

Closed
davep opened this issue Apr 26, 2023 · 1 comment · Fixed by #2803
Closed

List items in a Markdown can receive focus #2380

davep opened this issue Apr 26, 2023 · 1 comment · Fixed by #2803
Assignees
Labels
bug Something isn't working Task

Comments

@davep
Copy link
Contributor

davep commented Apr 26, 2023

It's possible that there are other items within Markdown for which this is true, and when I get a moment to test this more I'll update this issue if this is the case, but right now a Markdown that is showing markdown text that has ordered or unordered lists within it will have the focus chain work through each of the list items.

This can be seen by running this code and pressing Tab often:

from textual.app        import App, ComposeResult
from textual.containers import VerticalScroll
from textual.widgets    import Header, Footer, Markdown

MARKDOWN = """\
# Header

## Sub Header

- List
- List
- List
- List
- List
- List

1. Another List
1. Another List
1. Another List
1. Another List
1. Another List
1. Another List
"""

class MarkdownFocusApp( App[ None ] ):

    CSS = """
    *:focus {
        border: double red;
    }
    """

    def compose( self ) -> ComposeResult:
        yield Header()
        with VerticalScroll():
            yield Markdown(MARKDOWN)
        yield Footer()

if __name__ == "__main__":
    MarkdownFocusApp().run()
@davep davep added bug Something isn't working Task labels Apr 26, 2023
davep added a commit to davep/textual-sandbox that referenced this issue Apr 26, 2023
davep added a commit to davep/textual that referenced this issue Jun 19, 2023
@davep davep self-assigned this Jun 19, 2023
@davep davep linked a pull request Jun 19, 2023 that will close this issue
willmcgugan pushed a commit that referenced this issue Jun 20, 2023
* Initial set of Markdown widget unit tests

Noting too crazy or clever to start with, initially something to just test
the basics and to ensure that the resulting Textual node list is what we'd
expect.

Really just the start of a testing framework for Markdown.

* Allow handling of an unknown token

This allow for a couple of things:

1. First and foremost this will let me test for unhandled tokens in testing.
2. This will also let applications support other token types.

* Update the Markdown testing to get upset about unknown token types

* Treat a code_block markdown token the same as a fence

I believe this should be a fine way to solve this. I don't see anything that
means that a `code_block` is in any way different than a fenced block that
has no syntax specified.

See #2781.

* Add a test for a code_block within Markdown

* Allow for inline fenced code and code blocks

See #2676

Co-authored-by: TomJGooding <101601846+TomJGooding@users.noreply.github.com>

* Update the ChangeLog

* Improve the external Markdown elements are added to the document

* Improve the testing of Markdown

Also add a test for the list inline code block

* Remove the unnecessary pause

* Stop list items in Markdown being added to the focus chain

See #2380

* Remove hint to pyright/pylance/pylint that it's okay to ignore the arg

---------

Co-authored-by: TomJGooding <101601846+TomJGooding@users.noreply.github.com>
@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

Successfully merging a pull request may close this issue.

1 participant