Skip to content

Commit 318903d

Browse files
committed
Fixed anchor tracking not working for anchors in tables
1 parent 8a812ae commit 318903d

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

material/assets/javascripts/bundle.56861ea1.min.js renamed to material/assets/javascripts/bundle.2a903f2a.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/assets/javascripts/bundle.56861ea1.min.js.map renamed to material/assets/javascripts/bundle.2a903f2a.min.js.map

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/base.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@
240240
</script>
241241
{% endblock %}
242242
{% block scripts %}
243-
<script src="{{ 'assets/javascripts/bundle.56861ea1.min.js' | url }}"></script>
243+
<script src="{{ 'assets/javascripts/bundle.2a903f2a.min.js' | url }}"></script>
244244
{% for path in config.extra_javascript %}
245245
<script src="{{ path | url }}"></script>
246246
{% endfor %}

src/assets/javascripts/components/toc/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ export function watchTableOfContents(
176176
offset = target.offsetTop
177177
}
178178

179+
/* Fix anchor offsets in tables - see https://bit.ly/3CUFOcn */
180+
let parent = target.offsetParent as HTMLElement
181+
for (; parent; parent = parent.offsetParent as HTMLElement)
182+
offset += parent.offsetTop
183+
179184
/* Map reversed anchor path to vertical offset */
180185
return index.set(
181186
[...path = [...path, anchor]].reverse(),

0 commit comments

Comments
 (0)