Skip to content
Merged
5 changes: 4 additions & 1 deletion core/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1845,7 +1845,7 @@ ion-radio,part,container
ion-radio,part,label
ion-radio,part,mark

ion-radio-group,none
ion-radio-group,shadow
ion-radio-group,prop,allowEmptySelection,boolean,false,false,false
ion-radio-group,prop,compareWith,((currentValue: any, compareValue: any) => boolean) | null | string | undefined,undefined,false,false
ion-radio-group,prop,errorText,string | undefined,undefined,false,false
Expand All @@ -1855,6 +1855,9 @@ ion-radio-group,prop,name,string,this.inputId,false,false
ion-radio-group,prop,theme,"ios" | "md" | "ionic",undefined,false,false
ion-radio-group,prop,value,any,undefined,false,false
ion-radio-group,event,ionChange,RadioGroupChangeEventDetail<any>,true
ion-radio-group,part,error-text
ion-radio-group,part,helper-text
ion-radio-group,part,top

ion-range,shadow
ion-range,prop,activeBarStart,number | undefined,undefined,false,false
Expand Down
8 changes: 5 additions & 3 deletions core/src/components/radio-group/radio-group.common.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Radio Group: Common
// --------------------------------------------------

ion-radio-group {
:host {
display: block;

// Prevents additional pixels from being rendered on top
vertical-align: top;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This became unnecessary by introducing display: block

}
Expand All @@ -21,10 +23,10 @@ ion-radio-group {
display: block;
}

.ion-touched.ion-invalid .radio-group-top .error-text {
:host(.ion-touched.ion-invalid) .radio-group-top .error-text {
display: block;
}

.ion-touched.ion-invalid .radio-group-top .helper-text {
:host(.ion-touched.ion-invalid) .radio-group-top .helper-text {
display: none;
}
28 changes: 16 additions & 12 deletions core/src/components/radio-group/radio-group.ionic.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,20 @@

// Add padding to the error and helper text when used in a
// list to align them with the list header and item text.
ion-list .radio-group-top {
/* stylelint-disable */
@include globals.ltr() {
padding-right: globals.$ion-space-400;
padding-left: calc(globals.$ion-space-400 + var(--ion-safe-area-left, 0px));
}

@include globals.rtl() {
padding-right: calc(globals.$ion-space-400 + var(--ion-safe-area-right, 0px));
padding-left: globals.$ion-space-400;
}
/* stylelint-enable */
// Note: :host-context() cannot be nested inside ltr()/rtl() mixins
// because the mixin tries to transform the selector, creating invalid CSS.
// We work around this by using separate rules outside the mixins.
/* stylelint-disable */
:host-context(ion-list) .radio-group-top {
// Default to LTR - padding-left includes safe area
padding-right: globals.$ion-space-400;
padding-left: calc(globals.$ion-space-400 + var(--ion-safe-area-left, 0px));
}

// RTL support - match when document or ancestor has dir="rtl"
:host-context([dir="rtl"] ion-list) .radio-group-top,
:host-context(ion-list) .radio-group-top:dir(rtl) {
padding-right: calc(globals.$ion-space-400 + var(--ion-safe-area-right, 0px));
padding-left: globals.$ion-space-400;
}
/* stylelint-enable */
2 changes: 1 addition & 1 deletion core/src/components/radio-group/radio-group.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

// Add padding to the error and helper text when used in a
// list to align them with the list header and item text.
ion-list .radio-group-top {
:host-context(ion-list) .radio-group-top {
@include padding-horizontal($item-ios-padding-start, $item-ios-padding-end);
}
2 changes: 1 addition & 1 deletion core/src/components/radio-group/radio-group.md.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

// Add padding to the error and helper text when used in a
// list to align them with the list header and item text.
ion-list .radio-group-top {
:host-context(ion-list) .radio-group-top {
@include padding-horizontal($item-md-padding-start, $item-md-padding-end);
}
7 changes: 0 additions & 7 deletions core/src/components/radio-group/radio-group.native.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
@import "./radio-group.common";
@import "../../themes/native/native.globals";

// Radio Group: Native
// --------------------------------------------------

.radio-group-wrapper {
display: inline;
}

// Radio Group: Top
// --------------------------------------------------

Expand Down
16 changes: 5 additions & 11 deletions core/src/components/radio-group/radio-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type { RadioGroupChangeEventDetail, RadioGroupCompareFn } from './radio-g
md: 'radio-group.md.scss',
ionic: 'radio-group.ionic.scss',
},
shadow: true,
})
export class RadioGroup implements ComponentInterface {
private inputId = `ion-rg-${radioGroupIds++}`;
Expand Down Expand Up @@ -317,11 +318,11 @@ export class RadioGroup implements ComponentInterface {
}

return (
<div class="radio-group-top">
<div id={helperTextId} class="helper-text" aria-live="polite">
<div class="radio-group-top" part="top">
<div id={helperTextId} class="helper-text" part="helper-text" aria-live="polite">
{!isInvalid ? helperText : null}
</div>
<div id={errorTextId} class="error-text" role="alert">
<div id={errorTextId} class="error-text" part="error-text" role="alert">
{isInvalid ? errorText : null}
</div>
</div>
Expand Down Expand Up @@ -360,14 +361,7 @@ export class RadioGroup implements ComponentInterface {
onClick={this.onClick}
>
{this.renderHintText()}
{/*
TODO(FW-6279): Wrapping the slot in a div is a workaround due to a
Stencil issue. Without the wrapper, the children radio will fire the
blur event on focus, instead of waiting for them to be blurred.
*/}
<div class="radio-group-wrapper">
<slot></slot>
</div>
<slot></slot>
</Host>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
ion-radio {
width: 100%;
}
.custom .helper-text {
.custom::part(helper-text) {
color: green;
}
.custom .error-text {
.custom::part(error-text) {
color: purple;
}
</style>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, screenshot, co
await page.setContent(
`
<style>
.radio-group-top {
ion-radio-group::part(top) {
font-size: 20px;
}

.radio-group-top .helper-text {
ion-radio-group::part(helper-text) {
color: green;
}
</style>
Expand All @@ -222,11 +222,11 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, screenshot, co
await page.setContent(
`
<style>
.radio-group-top {
ion-radio-group::part(top) {
font-size: 20px;
}

.radio-group-top .error-text {
ion-radio-group::part(error-text) {
color: purple;
}
</style>
Expand Down
Loading