Changed default option to text.

This commit is contained in:
Satbir Singh 2020-02-24 14:55:09 +00:00
parent 4cb0e5c0cf
commit 9b7a0731e9
4 changed files with 11 additions and 4 deletions

View File

@ -44,7 +44,11 @@ class RadioGroupComponent extends React.Component<RadioGroupComponentProps> {
</Label> </Label>
)} )}
<StyledRadioGroup <StyledRadioGroup
selectedValue={this.props.selectedOptionValue} selectedValue={
this.props.selectedOptionValue === undefined
? this.props.defaultOptionValue
: this.props.selectedOptionValue
}
onChange={this.onRadioSelectionChange} onChange={this.onRadioSelectionChange}
> >
{this.props.options.map(option => { {this.props.options.map(option => {
@ -73,6 +77,7 @@ export interface RadioGroupComponentProps extends ComponentProps {
onRadioSelectionChange: (updatedOptionValue: string) => void; onRadioSelectionChange: (updatedOptionValue: string) => void;
selectedOptionValue: string; selectedOptionValue: string;
isLoading: boolean; isLoading: boolean;
defaultOptionValue: string;
} }
export default RadioGroupComponent; export default RadioGroupComponent;

View File

@ -567,7 +567,7 @@ const PropertyPaneConfigResponse = {
id: "16.2", id: "16.2",
propertyName: "defaultOptionValue", propertyName: "defaultOptionValue",
label: "Default Selected Value", label: "Default Selected Value",
controlType: "SWITCH", controlType: "INPUT_TEXT",
}, },
{ {
id: "16.3", id: "16.3",

View File

@ -137,7 +137,7 @@ const WidgetConfigResponse: WidgetConfigReducerState = {
{ id: "2", label: "Bravo", value: "2" }, { id: "2", label: "Bravo", value: "2" },
{ id: "3", label: "Charlie", value: "3" }, { id: "3", label: "Charlie", value: "3" },
], ],
selectedOptionValue: "1", defaultOptionValue: "1",
widgetName: "RadioGroup", widgetName: "RadioGroup",
}, },
ALERT_WIDGET: { ALERT_WIDGET: {

View File

@ -33,6 +33,7 @@ class RadioGroupWidget extends BaseWidget<RadioGroupWidgetProps, WidgetState> {
onRadioSelectionChange={this.onRadioSelectionChange} onRadioSelectionChange={this.onRadioSelectionChange}
key={this.props.widgetId} key={this.props.widgetId}
label={this.props.label} label={this.props.label}
defaultOptionValue={this.props.defaultOptionValue}
selectedOptionValue={this.props.selectedOptionValue} selectedOptionValue={this.props.selectedOptionValue}
options={this.props.options} options={this.props.options}
isLoading={this.props.isLoading} isLoading={this.props.isLoading}
@ -41,7 +42,7 @@ class RadioGroupWidget extends BaseWidget<RadioGroupWidgetProps, WidgetState> {
} }
onRadioSelectionChange = (updatedValue: string) => { onRadioSelectionChange = (updatedValue: string) => {
this.updateWidgetProperty("selectedOptionValue", updatedValue); super.updateWidgetMetaProperty("selectedOptionValue", updatedValue);
if (this.props.onSelectionChange) { if (this.props.onSelectionChange) {
super.executeAction({ super.executeAction({
dynamicString: this.props.onSelectionChange, dynamicString: this.props.onSelectionChange,
@ -68,6 +69,7 @@ export interface RadioGroupWidgetProps extends WidgetProps {
options: RadioOption[]; options: RadioOption[];
selectedOptionValue: string; selectedOptionValue: string;
onSelectionChange: string; onSelectionChange: string;
defaultOptionValue: string;
} }
export default RadioGroupWidget; export default RadioGroupWidget;