Skip to content

Commit

Permalink
fix: single input do not map fields when typing
Browse files Browse the repository at this point in the history
  • Loading branch information
soleksy-splunk committed Sep 25, 2024
1 parent 46fc66f commit 1a762e3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
9 changes: 5 additions & 4 deletions ui/src/components/FormModifications/FormModifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ const getModificationForEntity = (
// do not compare empty values for modifications
currentFieldValue !== undefined &&
currentFieldValue !== null &&
// here type convertion is needed as splunk keeps all data as string
// and users can put numbers or booleans inside global config
getValueMapTruthyFalse(currentFieldValue, page) ===
getValueMapTruthyFalse(mod.fieldValue, page) &&
// values are directly equal or they are equal after type convertion
(currentFieldValue === mod.fieldValue ||
// here convertion is needed as splunk keeps boolsih data on cponfiguration page as 1 and 0
getValueMapTruthyFalse(currentFieldValue, page) ===
getValueMapTruthyFalse(mod.fieldValue, page)) &&
(!mod.mode || mod.mode === mode)
);
});
Expand Down
14 changes: 6 additions & 8 deletions ui/src/components/SingleInputComponent/SingleInputComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ function SingleInputComponent(props: SingleInputComponentProps) {
hideClearBtn,
} = controlOptions;

function handleChange(e: unknown, obj: { value: string | number | boolean }) {
const handleChange = (e: unknown, obj: { value: string | number | boolean }) => {
restProps.handleChange(field, obj.value);
}
};
const Option = createSearchChoice ? ComboBox.Option : Select.Option;
const Heading = createSearchChoice ? ComboBox.Heading : Select.Heading;

Expand Down Expand Up @@ -178,12 +178,11 @@ function SingleInputComponent(props: SingleInputComponentProps) {
return createSearchChoice ? (
<StyledDiv className="dropdownBox">
<ComboBox
// do not map empty values like '', null, undefined
value={props.value ? getValueMapTruthyFalse(props.value, props.page) : ''}
value={props.value}
name={field}
error={error}
disabled={effectiveDisabled}
onChange={handleChange} // eslint-disable-line react/jsx-no-bind
onChange={handleChange}
inline
>
{options && options.length > 0 && options}
Expand All @@ -196,12 +195,11 @@ function SingleInputComponent(props: SingleInputComponentProps) {
inputId={props.id}
className="dropdownBox"
data-test-loading={loading}
// do not map empty values like '', null, undefined
value={props.value ? getValueMapTruthyFalse(props.value, props.page) : props.value}
value={props.value}
name={field}
error={error}
disabled={effectiveDisabled}
onChange={handleChange} // eslint-disable-line react/jsx-no-bind
onChange={handleChange}
filter={!disableSearch}
inline
>
Expand Down

0 comments on commit 1a762e3

Please sign in to comment.