Skip to content

Commit fb05a3a

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 fb05a3a

File tree

1 file changed

+11
-3
lines changed
  • src/frontend/apps/impress/src/features/docs/doc-export

1 file changed

+11
-3
lines changed

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

Lines changed: 11 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,19 @@ 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 = previousInfo && info.blockOuterIndex === previousInfo.blockOuterIndex + 1;
223227
const continuesPreviousList =
224-
previousInfo &&
228+
isAdjacentBlock &&
225229
previousInfo.contentType === contentType &&
226230
previousInfo.level === level;
227231

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

0 commit comments

Comments
 (0)