From 246c16a5f31243d141896cb97efe527c011246cd Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Fri, 24 Mar 2023 14:26:10 +0000 Subject: [PATCH 1/4] test(radio-group): add failing test --- .../radio-group/test/form/radio-group.e2e.ts | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/core/src/components/radio-group/test/form/radio-group.e2e.ts b/core/src/components/radio-group/test/form/radio-group.e2e.ts index 83a457c889a..3a23643514c 100644 --- a/core/src/components/radio-group/test/form/radio-group.e2e.ts +++ b/core/src/components/radio-group/test/form/radio-group.e2e.ts @@ -31,3 +31,30 @@ test.describe('radio-group: form', () => { await expect(value).toHaveText(''); }); }); + +test.describe.only('radio-group: form submission', () => { + test('should submit radio data in a form', async ({ page, skip }) => { + skip.rtl(); + skip.mode('md'); + + await page.setContent(` +
+ + + + + +
+ `); + + const radioGroupData = await page.evaluate(() => { + const form = document.querySelector('form'); + if (!form) { return; } + + const formData = new FormData(form); + return formData.get('my-group'); + }); + + await expect(radioGroupData).toBe('a'); + }); +}) From 1385c550c8e937524052d73e6ff5281b14812b2d Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Fri, 24 Mar 2023 14:32:21 +0000 Subject: [PATCH 2/4] fix(radio-group): radios participate in form submission --- core/src/components/radio-group/radio-group.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/components/radio-group/radio-group.tsx b/core/src/components/radio-group/radio-group.tsx index 31cc09016fc..d581d1af6a8 100644 --- a/core/src/components/radio-group/radio-group.tsx +++ b/core/src/components/radio-group/radio-group.tsx @@ -3,6 +3,7 @@ import { Component, Element, Event, Host, Listen, Prop, Watch, h } from '@stenci import { getIonMode } from '../../global/ionic-global'; import type { RadioGroupChangeEventDetail } from '../../interface'; +import { renderHiddenInput } from '../../utils/helpers'; @Component({ tag: 'ion-radio-group', @@ -156,9 +157,11 @@ export class RadioGroup implements ComponentInterface { } render() { - const { label, labelId } = this; + const { label, labelId, el, name, value } = this; const mode = getIonMode(this); + renderHiddenInput(true, el, name, value, false); + return ; } } From b8db647462cc06d20683d9134f3d27349ba46a4d Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Fri, 24 Mar 2023 14:32:29 +0000 Subject: [PATCH 3/4] remove only --- .../components/radio-group/test/form/radio-group.e2e.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/components/radio-group/test/form/radio-group.e2e.ts b/core/src/components/radio-group/test/form/radio-group.e2e.ts index 3a23643514c..5c3875d6e70 100644 --- a/core/src/components/radio-group/test/form/radio-group.e2e.ts +++ b/core/src/components/radio-group/test/form/radio-group.e2e.ts @@ -32,7 +32,7 @@ test.describe('radio-group: form', () => { }); }); -test.describe.only('radio-group: form submission', () => { +test.describe('radio-group: form submission', () => { test('should submit radio data in a form', async ({ page, skip }) => { skip.rtl(); skip.mode('md'); @@ -49,7 +49,9 @@ test.describe.only('radio-group: form submission', () => { const radioGroupData = await page.evaluate(() => { const form = document.querySelector('form'); - if (!form) { return; } + if (!form) { + return; + } const formData = new FormData(form); return formData.get('my-group'); @@ -57,4 +59,4 @@ test.describe.only('radio-group: form submission', () => { await expect(radioGroupData).toBe('a'); }); -}) +}); From 195a33294eab13fc20cc5e1771b2c8398d923111 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Fri, 24 Mar 2023 14:40:41 +0000 Subject: [PATCH 4/4] add test annotation --- core/src/components/radio-group/test/form/radio-group.e2e.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/components/radio-group/test/form/radio-group.e2e.ts b/core/src/components/radio-group/test/form/radio-group.e2e.ts index 5c3875d6e70..4b233c557ad 100644 --- a/core/src/components/radio-group/test/form/radio-group.e2e.ts +++ b/core/src/components/radio-group/test/form/radio-group.e2e.ts @@ -37,6 +37,11 @@ test.describe('radio-group: form submission', () => { skip.rtl(); skip.mode('md'); + test.info().annotations.push({ + type: 'issue', + description: 'https://github.com/ionic-team/ionic-framework/issues/27016', + }); + await page.setContent(`