Skip to content

Commit

Permalink
🐛 Use onChange() instead of setValue() (#1319)
Browse files Browse the repository at this point in the history
Resolves #1317

---------

Signed-off-by: Gilles Dubreuil <[email protected]>
  • Loading branch information
gildub authored Aug 29, 2023
1 parent 3c4d31e commit ba82364
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const SetMode: React.FC<ISetMode> = ({ isSingleApp, isModeValid }) => {
label={t("wizard.label.analysisSource")}
fieldId="analysis-mode"
isRequired
renderInput={({ field: { value, name } }) => (
renderInput={({ field: { value, name, onChange } }) => (
<SimpleSelect
id="analysis-mode"
toggleId="analysis-mode-toggle"
Expand All @@ -68,8 +68,8 @@ export const SetMode: React.FC<ISetMode> = ({ isSingleApp, isModeValid }) => {
variant="single"
value={toOptionLike(value, options)}
onChange={(selection) => {
const option = selection as OptionWithValue<AnalysisMode>;
setValue(name, option.value);
const selectionValue = selection as OptionWithValue<AnalysisMode>;
onChange(selectionValue.value);
}}
options={options}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ export const IdentityForm: React.FC<IdentityFormProps> = ({
label="Type"
fieldId="type-select"
isRequired
renderInput={({ field: { value, name } }) => (
renderInput={({ field: { value, name, onChange } }) => (
<SimpleSelect
id="type-select"
toggleId="type-select-toggle"
Expand All @@ -475,7 +475,7 @@ export const IdentityForm: React.FC<IdentityFormProps> = ({
options={kindOptions}
onChange={(selection) => {
const selectionValue = selection as OptionWithValue<IdentityKind>;
setValue(name, selectionValue.value);
onChange(selectionValue.value);
// So we don't retain the values from the wrong type of credential
resetField("user");
resetField("password");
Expand All @@ -492,7 +492,7 @@ export const IdentityForm: React.FC<IdentityFormProps> = ({
label="User credentials"
isRequired
fieldId="user-credentials-select"
renderInput={({ field: { value, name } }) => (
renderInput={({ field: { value, name, onChange } }) => (
<SimpleSelect
id="user-credentials-select"
toggleId="user-credentials-select-toggle"
Expand All @@ -507,7 +507,7 @@ export const IdentityForm: React.FC<IdentityFormProps> = ({
onChange={(selection) => {
const selectionValue =
selection as OptionWithValue<UserCredentials>;
setValue(name, selectionValue.value);
onChange(selectionValue.value);
// So we don't retain the values from the wrong type of credential
resetField("user");
resetField("password");
Expand Down

0 comments on commit ba82364

Please sign in to comment.