Skip to content

Commit

Permalink
Set unit settings to undefined on clear unit type (#21399)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxiadlovskii authored Jan 22, 2025
1 parent cd3e38f commit deb945c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions changelog/unreleased/issue-21398.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type = "f"
message = "Fix an issue causing saving searches/dashboards after clearing the unit type to fail with error."

pulls = ["21399"]
issues = ["21398"]
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ const FieldUnitPopover = ({ field, predefinedUnit }: { field: string, predefined
.map(({ abbrev, name }: Unit) => ({ value: abbrev, label: capitalize(name) })), [currentUnitType]);
const toggleShow = () => setShow((cur) => !cur);
const onUnitTypeChange = useCallback((val: string) => {
setFieldValue(`units.${field}`, { unitType: val || undefined, abbrev: undefined });
const fieldUnitSettings = val
? { unitType: val, abbrev: undefined }
: undefined;
setFieldValue(`units.${field}`, fieldUnitSettings);
}, [field, setFieldValue]);

const badgeLabel = useMemo(() => {
Expand Down

0 comments on commit deb945c

Please sign in to comment.