Skip to content

Commit faeea17

Browse files
committed
fix(pat autotoc): Fix for having duplicated ids incase of multiple autotoc elements
1 parent b7ffd36 commit faeea17

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/pat/autotoc/autotoc.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export default Base.extend({
2828

2929
var self = this;
3030

31+
const autotocInstances = $(".pat-autotoc");
32+
self.instanceIndex = autotocInstances.index(self.$el);
33+
3134
const $nav = $("<nav/>")
3235
.attr("aria-label", "Tab Navigation");
3336

@@ -81,7 +84,7 @@ export default Base.extend({
8184
const $section = $level.closest(self.options.section);
8285
let sectionId = $section.prop("id");
8386
let sectionHash = `#${sectionId}`;
84-
const tabId = `${self.options.IDPrefix}${self.name}-${i}`;
87+
const tabId = `${self.options.IDPrefix}${self.name}-${self.instanceIndex}-${i}`;
8588
const tabHash = `#${tabId}`;
8689
const levelId = `${tabId}-pane`;
8790
const levelHash = `#${levelId}`;

0 commit comments

Comments
 (0)