Skip to content

Commit

Permalink
Merge pull request #4583 from davep/fix-goto-anchor
Browse files Browse the repository at this point in the history
Fix `Markdown.goto_anchor` not scrolling the heading into view
  • Loading branch information
willmcgugan authored Jun 2, 2024
2 parents a44119d + f27a921 commit 1681cca
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
12 changes: 9 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

### Fixed

- Fixed `Markdown.goto_anchor` no longer scrolling the heading into view https://github.com/Textualize/textual/pull/4583

## [0.63.6] - 2024-05-29

### Fixed
Expand Down Expand Up @@ -99,7 +105,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- Dependency issue

## [0.60.0] - 2024-05-14
## [0.60.0] - 2024-05-14

### Fixed

Expand Down Expand Up @@ -206,7 +212,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added

- Added `Size.with_width` and `Size.with_height` https://github.com/Textualize/textual/pull/4393

### Fixed

- Fixed issue with inline mode and multiple screens https://github.com/Textualize/textual/pull/4393
Expand All @@ -221,7 +227,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

- Fixed mouse escape sequences being generated with `mouse=False`
- Fixed mouse escape sequences being generated with `mouse=False`

## [0.55.0] - 2024-04-1

Expand Down
20 changes: 10 additions & 10 deletions src/textual/widgets/_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class MarkdownHeader(MarkdownBlock):
MarkdownHeader {
color: $text;
margin: 2 0 1 0;
}
"""

Expand All @@ -243,7 +243,7 @@ class MarkdownH1(MarkdownHeader):
DEFAULT_CSS = """
MarkdownH1 {
content-align: center middle;
content-align: center middle;
text-style: bold;
color: $success;
&:light {color: $primary;}
Expand All @@ -260,7 +260,7 @@ class MarkdownH2(MarkdownHeader):
text-style: underline;
color: $success;
&:light {color: $primary;}
}
"""

Expand All @@ -270,7 +270,7 @@ class MarkdownH3(MarkdownHeader):

DEFAULT_CSS = """
MarkdownH3 {
text-style: bold;
color: $success;
&:light {color: $primary;}
Expand Down Expand Up @@ -300,7 +300,7 @@ class MarkdownH5(MarkdownHeader):
text-style: bold;
color: $text;
margin: 1 0;
}
"""

Expand Down Expand Up @@ -493,8 +493,8 @@ class MarkdownTable(MarkdownBlock):

DEFAULT_CSS = """
MarkdownTable {
width: 100%;
background: $panel;
width: 100%;
background: $panel;
}
"""

Expand Down Expand Up @@ -597,11 +597,11 @@ class MarkdownFence(MarkdownBlock):
margin: 1 0;
overflow: auto;
width: 100%;
height: auto;
height: auto;
max-height: 20;
color: rgb(210,210,210);
}
MarkdownFence > * {
Expand Down Expand Up @@ -839,7 +839,7 @@ def goto_anchor(self, anchor: str) -> bool:
unique = TrackedSlugs()
for _, title, header_id in self._table_of_contents:
if unique.slug(title) == anchor:
self.parent.scroll_to_widget(self.query_one(f"#{header_id}"), top=True)
self.query_one(f"#{header_id}").scroll_visible(top=True)
return True
return False

Expand Down

0 comments on commit 1681cca

Please sign in to comment.