Skip to content

Commit e811b93

Browse files
author
DavidQ
committed
Fix Paths or IDs accordion collapse behavior in Preview Generator V2 - PR_26126_045-preview-generator-v2-paths-accordion-collapse-fix
1 parent 50e5259 commit e811b93

3 files changed

Lines changed: 115 additions & 1 deletion

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
PR_26126_045 Preview Generator V2 Paths accordion collapse fix
2+
3+
Scope
4+
- Updated Preview Generator V2 accordion behavior only.
5+
- Updated tools/preview-generator-v2/previewGeneratorV2.css.
6+
- Extended tests/playwright/PreviewGeneratorV2Baseline.spec.mjs to assert the Paths or IDs collapse/expand contract.
7+
- No samples, schemas, or start_of_day files were modified.
8+
9+
Fix
10+
- The Paths or IDs section had a center-panel stretch rule that applied whether the accordion was open or collapsed.
11+
- Changed the stretch rule to apply only when .preview-generator-v2__paths-section.is-open is present.
12+
- Added a collapsed rule so .preview-generator-v2__paths-section:not(.is-open) returns to header-only sizing.
13+
- Added an explicit hidden-content guard for .preview-generator-v2__paths-section .accordion-v2__content[hidden].
14+
15+
Behavior preserved
16+
- Expanded Paths or IDs keeps the stretched center layout.
17+
- Collapsed Paths or IDs hides the content area and textarea.
18+
- Reopened Paths or IDs restores the stretched textarea/content layout.
19+
- Accordion aria-expanded and data-accordion-v2-icon-state continue to update through AccordionSection.
20+
- Generation behavior was not changed.
21+
22+
Validation
23+
- node --check tests/playwright/PreviewGeneratorV2Baseline.spec.mjs passed.
24+
- npm run test:workspace-v2 passed.
25+
- Result: 3 passed.
26+
- Confirmed no samples, schemas, or start_of_day changes.
27+
28+
Playwright coverage
29+
- Added a specific Paths or IDs accordion assertion that verifies:
30+
- expanded content is visible and flex-stretched.
31+
- collapsed content is hidden.
32+
- textarea is hidden when collapsed.
33+
- collapsed Paths section is no longer flex-stretched.
34+
- reopened content is visible and flex-stretched again.
35+
- icon state changes closed/open.
36+
37+
Full samples smoke test
38+
- Skipped intentionally.
39+
- Reason: this PR is a targeted Preview Generator V2 accordion/CSS fix and does not modify sample JSON, sample launch code, or shared sample runtime behavior.
40+
41+
Manual validation
42+
- Open tools/preview-generator-v2/index.html.
43+
- Collapse Paths or IDs and confirm only the header remains visible.
44+
- Reopen Paths or IDs and confirm the textarea returns and fills the available center space.
45+
- Confirm Generate Preview behavior is unchanged.

tests/playwright/PreviewGeneratorV2Baseline.spec.mjs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,75 @@ async function openPreviewGenerator(page, { withFakeRepo = false, validSampleIds
112112
async function expectAccordionToggles(page, contentId) {
113113
const header = page.locator(`.accordion-v2__header[aria-controls="${contentId}"]`);
114114
const content = page.locator(`#${contentId}`);
115+
const icon = header.locator(".accordion-v2__icon");
115116
await expect(header).toBeVisible();
116117
await expect(content).toBeVisible();
117118

118119
await header.click();
119120
await expect(content).toBeHidden();
120121
await expect(header).toHaveAttribute("aria-expanded", "false");
122+
await expect(icon).toHaveAttribute("data-accordion-v2-icon-state", "closed");
121123

122124
await header.click();
123125
await expect(content).toBeVisible();
124126
await expect(header).toHaveAttribute("aria-expanded", "true");
127+
await expect(icon).toHaveAttribute("data-accordion-v2-icon-state", "open");
128+
}
129+
130+
async function expectPathsOrIdsAccordionToggles(page) {
131+
const header = page.locator('.accordion-v2__header[aria-controls="pathsOrIdsContent"]');
132+
const content = page.locator("#pathsOrIdsContent");
133+
const textarea = page.locator("#sampleList");
134+
const icon = header.locator(".accordion-v2__icon");
135+
136+
const readLayout = async () => await page.evaluate(() => {
137+
const section = document.querySelector(".preview-generator-v2__paths-section");
138+
const contentEl = document.getElementById("pathsOrIdsContent");
139+
const textareaEl = document.getElementById("sampleList");
140+
return {
141+
sectionFlex: getComputedStyle(section).flex,
142+
sectionHeight: section.getBoundingClientRect().height,
143+
contentDisplay: getComputedStyle(contentEl).display,
144+
contentHidden: contentEl.hidden,
145+
textareaHeight: textareaEl.getBoundingClientRect().height,
146+
textareaHidden: textareaEl.checkVisibility ? !textareaEl.checkVisibility() : textareaEl.offsetParent === null
147+
};
148+
});
149+
150+
await expect(header).toBeVisible();
151+
await expect(content).toBeVisible();
152+
await expect(textarea).toBeVisible();
153+
const expanded = await readLayout();
154+
expect(expanded.sectionFlex).toContain("1 1");
155+
expect(expanded.contentDisplay).toBe("flex");
156+
expect(expanded.contentHidden).toBe(false);
157+
expect(expanded.textareaHeight).toBeGreaterThan(0);
158+
expect(expanded.textareaHidden).toBe(false);
159+
160+
await header.click();
161+
await expect(content).toBeHidden();
162+
await expect(textarea).toBeHidden();
163+
await expect(header).toHaveAttribute("aria-expanded", "false");
164+
await expect(icon).toHaveAttribute("data-accordion-v2-icon-state", "closed");
165+
const collapsed = await readLayout();
166+
expect(collapsed.sectionFlex).toContain("0 0");
167+
expect(collapsed.contentDisplay).toBe("none");
168+
expect(collapsed.contentHidden).toBe(true);
169+
expect(collapsed.textareaHeight).toBe(0);
170+
expect(collapsed.textareaHidden).toBe(true);
171+
expect(collapsed.sectionHeight).toBeLessThanOrEqual(expanded.sectionHeight);
172+
173+
await header.click();
174+
await expect(content).toBeVisible();
175+
await expect(textarea).toBeVisible();
176+
await expect(header).toHaveAttribute("aria-expanded", "true");
177+
await expect(icon).toHaveAttribute("data-accordion-v2-icon-state", "open");
178+
const reopened = await readLayout();
179+
expect(reopened.sectionFlex).toContain("1 1");
180+
expect(reopened.contentDisplay).toBe("flex");
181+
expect(reopened.contentHidden).toBe(false);
182+
expect(reopened.textareaHeight).toBeGreaterThan(0);
183+
expect(reopened.textareaHidden).toBe(false);
125184
}
126185

127186
test.describe("Preview Generator V2 baseline", () => {
@@ -243,6 +302,7 @@ test.describe("Preview Generator V2 baseline", () => {
243302
expect(pathsLayout.resize).toBe("none");
244303
expect(pathsLayout.contentHeight - pathsLayout.inputHeight).toBeLessThan(40);
245304
expect(pathsLayout.contentWidth - pathsLayout.inputWidth).toBeLessThan(40);
305+
await expectPathsOrIdsAccordionToggles(page);
246306

247307
await page.locator("#pickRepoBtn").click();
248308
await expect(page.locator("#repoSelectedValue")).toHaveText("HTML-JavaScript-Gaming");

tools/preview-generator-v2/previewGeneratorV2.css

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,25 @@ body.tools-platform-tool-page[data-tool-id="preview-generator-v2"] > .palette-ma
2222
overflow: hidden;
2323
}
2424

25-
.preview-generator-v2__center-panel .preview-generator-v2__paths-section {
25+
.preview-generator-v2__center-panel .preview-generator-v2__paths-section.is-open {
2626
flex: 1 1 auto;
2727
min-height: 0;
2828
}
2929

30+
.preview-generator-v2__center-panel .preview-generator-v2__paths-section:not(.is-open) {
31+
flex: 0 0 auto;
32+
min-height: 0;
33+
}
34+
3035
.preview-generator-v2__paths-section .accordion-v2__content {
3136
flex: 1 1 auto;
3237
min-height: 0;
3338
}
3439

40+
.preview-generator-v2__paths-section .accordion-v2__content[hidden] {
41+
display: none;
42+
}
43+
3544
.preview-generator-v2__left-accordion .accordion-v2__content {
3645
overflow: visible;
3746
}

0 commit comments

Comments
 (0)