Skip to content

Commit dda53ca

Browse files
committed
robot fixes
1 parent f426e86 commit dda53ca

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

src/components/onboarding/index.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -276,35 +276,35 @@ export function updateElementsVisibilityForOptions(
276276
// Check line before open wrapper
277277
if (openIndex > 0) {
278278
const prevLine = allLines[openIndex - 1];
279-
const prevText = prevLine.textContent?.trim();
280-
if (!prevText || prevText === '') {
281-
prevLine.style.display = 'none';
279+
if (!prevLine.textContent?.trim()) {
280+
prevLine.classList.add('hidden');
281+
prevLine.dataset.emptyLineHidden = 'true';
282282
}
283283
}
284284

285285
// Check line after close wrapper
286286
if (closeIndex < allLines.length - 1) {
287287
const nextLine = allLines[closeIndex + 1];
288-
const nextText = nextLine.textContent?.trim();
289-
if (!nextText || nextText === '') {
290-
nextLine.style.display = 'none';
288+
if (!nextLine.textContent?.trim()) {
289+
nextLine.classList.add('hidden');
290+
nextLine.dataset.emptyLineHidden = 'true';
291291
}
292292
}
293293
} else {
294294
// Show empty lines when integrations are visible
295295
if (openIndex > 0) {
296296
const prevLine = allLines[openIndex - 1];
297-
const prevText = prevLine.textContent?.trim();
298-
if (!prevText || prevText === '') {
299-
prevLine.style.display = '';
297+
if (prevLine.dataset.emptyLineHidden === 'true') {
298+
prevLine.classList.remove('hidden');
299+
delete prevLine.dataset.emptyLineHidden;
300300
}
301301
}
302302

303303
if (closeIndex < allLines.length - 1) {
304304
const nextLine = allLines[closeIndex + 1];
305-
const nextText = nextLine.textContent?.trim();
306-
if (!nextText || nextText === '') {
307-
nextLine.style.display = '';
305+
if (nextLine.dataset.emptyLineHidden === 'true') {
306+
nextLine.classList.remove('hidden');
307+
delete nextLine.dataset.emptyLineHidden;
308308
}
309309
}
310310
}

src/rehype-onboarding-lines.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,25 @@ function handle_inline_options(node) {
6868
if (lineStr.match(/integrations:\s*\[/)) {
6969
// Mark the opening line and hide it by default
7070
line.properties['data-integrations-wrapper'] = 'open';
71-
line.properties.className = [...(line.properties.className || []), 'hidden'];
71+
const openClasses = Array.isArray(line.properties.className)
72+
? line.properties.className
73+
: line.properties.className
74+
? [line.properties.className]
75+
: [];
76+
line.properties.className = [...openClasses, 'hidden'];
7277

73-
// Find the closing "],"
78+
// Find the closing "]," - must be exactly ],
7479
for (let j = i + 1; j < node.children.length; j++) {
7580
const closeStr = toString(node.children[j]).trim();
76-
if (closeStr.includes('],')) {
81+
if (closeStr === '],') {
7782
// Mark the closing line and hide it by default
7883
node.children[j].properties['data-integrations-wrapper'] = 'close';
79-
node.children[j].properties.className = [
80-
...(node.children[j].properties.className || []),
81-
'hidden',
82-
];
84+
const closeClasses = Array.isArray(node.children[j].properties.className)
85+
? node.children[j].properties.className
86+
: node.children[j].properties.className
87+
? [node.children[j].properties.className]
88+
: [];
89+
node.children[j].properties.className = [...closeClasses, 'hidden'];
8390
break;
8491
}
8592
}

0 commit comments

Comments
 (0)