Skip to content

Commit 521328f

Browse files
committed
Fix an issue with radio buttons default state
fixes #751
1 parent 60b4302 commit 521328f

File tree

3 files changed

+43
-19
lines changed

3 files changed

+43
-19
lines changed

sqlpage/templates/form.handlebars

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
{{#if (or (eq type "radio") (eq type "checkbox"))}}
1818
<div class="form-selectgroup form-selectgroup-boxes d-flex flex-column mx-0 my-1 col-md-{{default width 12}}">
1919
<label class="form-selectgroup-item flex-fill mx-0">
20-
<input type="{{type}}" {{#if id}}id="{{id}}" {{/if}}name="{{name}}" value="{{value}}" {{#if required}}required{{/if}} {{#if (or checked value)}}checked{{/if}} class="form-selectgroup-input">
20+
<input type="{{type}}" {{#if id}}id="{{id}}" {{/if}}name="{{name}}" value="{{value}}" {{#if required}}required{{/if}} {{#if checked}}checked{{/if}} class="form-selectgroup-input">
2121
<div class="form-selectgroup-label d-flex align-items-center p-3">
2222
<div class="me-3">
2323
<span class="form-selectgroup-check"></span>

tests/end-to-end/official-site.spec.ts

+24
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,27 @@ test("no console errors on map page", async ({ page }) => {
153153
test("no console errors on card page", async ({ page }) => {
154154
await checkNoConsoleErrors(page, "card");
155155
});
156+
157+
test("form component documentation", async ({ page }) => {
158+
await page.goto(`${BASE}/component.sql?component=form`);
159+
160+
// Find the form that contains radio buttons for component selection
161+
const componentForm = page.locator('form', {
162+
has: page.getByRole('radio', { name: 'Chart' })
163+
});
164+
165+
// the form should be visible
166+
await expect(componentForm).toBeVisible();
167+
168+
// Check that "form" is the first and default selected option
169+
const mapRadio = componentForm.getByRole("radio", { name: "Map" });
170+
await expect(mapRadio).toHaveValue("map");
171+
await expect(mapRadio).toBeChecked();
172+
173+
// Select "Chart" option and submit
174+
await componentForm.getByLabel("Chart").click({ force: true });
175+
await componentForm.getByRole("button", { name: "Submit" }).click();
176+
177+
// Verify we're on the chart documentation page
178+
await expect(page.getByRole("heading", { name: /chart/i, level: 1 })).toBeVisible();
179+
});

tests/end-to-end/package-lock.json

+18-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)