feat(radio-group): add compareWith property (#28452)

This commit is contained in:
Shawn Taylor
2023-11-09 10:21:55 -05:00
committed by GitHub
parent 27c4d194c5
commit 0ae327f0e0
12 changed files with 266 additions and 40 deletions

View File

@ -1,7 +1,7 @@
import type { ComponentInterface, EventEmitter } from '@stencil/core';
import { Component, Element, Event, Host, Method, Prop, State, Watch, h } from '@stencil/core';
import type { LegacyFormController } from '@utils/forms';
import { createLegacyFormController } from '@utils/forms';
import { createLegacyFormController, isOptionSelected } from '@utils/forms';
import { addEventListener, getAriaLabel, removeEventListener } from '@utils/helpers';
import { printIonWarning } from '@utils/logging';
import { createColorClasses, hostContext } from '@utils/theme';
@ -196,7 +196,9 @@ export class Radio implements ComponentInterface {
private updateState = () => {
if (this.radioGroup) {
this.checked = this.radioGroup.value === this.value;
const { compareWith, value: radioGroupValue } = this.radioGroup;
this.checked = isOptionSelected(radioGroupValue, this.value, compareWith);
}
};