Skip to content

Commit 03c049f

Browse files
committed
♿️(frontend) fix list merging across headings in HTML export
Lists separated by a heading were merged into a single <ul>
1 parent 43d4866 commit 03c049f

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

  • src/frontend/apps/impress/src/features/docs/doc-export

src/frontend/apps/impress/src/features/docs/doc-export/utils_html.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,11 @@ export const improveHtmlAccessibility = (
190190
listItem: HTMLElement;
191191
contentType: string;
192192
level: number;
193+
blockOuterIndex: number;
193194
}
194195

195196
const listItemsInfo: ListItemInfo[] = [];
196-
allBlockOuters.forEach((blockOuter) => {
197+
allBlockOuters.forEach((blockOuter, index) => {
197198
const listItem = blockOuter.querySelector<HTMLElement>(listItemSelector);
198199
if (listItem) {
199200
const contentType = listItem.getAttribute('data-content-type');
@@ -204,6 +205,7 @@ export const improveHtmlAccessibility = (
204205
listItem,
205206
contentType,
206207
level,
208+
blockOuterIndex: index,
207209
});
208210
}
209211
}
@@ -218,13 +220,20 @@ export const improveHtmlAccessibility = (
218220
const isBullet = contentType === 'bulletListItem';
219221
const listTag = isBullet ? 'ul' : 'ol';
220222

221-
// Check if previous item continues the same list (same type and level)
223+
// Check if previous item continues the same list (same type, level, and
224+
// no non-list block between them in the DOM : e.g. a heading separates lists).
222225
const previousInfo = idx > 0 ? listItemsInfo[idx - 1] : null;
226+
const isAdjacentBlock =
227+
previousInfo && info.blockOuterIndex === previousInfo.blockOuterIndex + 1;
223228
const continuesPreviousList =
224-
previousInfo &&
229+
isAdjacentBlock &&
225230
previousInfo.contentType === contentType &&
226231
previousInfo.level === level;
227232

233+
if (previousInfo && !isAdjacentBlock) {
234+
listStack.length = 0;
235+
}
236+
228237
// Find or create the appropriate list
229238
let targetList: HTMLElement | null = null;
230239

0 commit comments

Comments
 (0)