diff --git a/ts/deckoptions/RevertButton.svelte b/ts/deckoptions/RevertButton.svelte index dd2c0b720..9f7afaa50 100644 --- a/ts/deckoptions/RevertButton.svelte +++ b/ts/deckoptions/RevertButton.svelte @@ -6,7 +6,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import * as tr from "lib/i18n"; import { revertIcon } from "./icons"; import { createEventDispatcher } from "svelte"; - import { isEqual, cloneDeep } from "lodash-es"; + import { isEqual as isEqualLodash, cloneDeep } from "lodash-es"; // import { onMount } from "svelte"; // import Tooltip from "bootstrap/js/dist/tooltip"; @@ -26,6 +26,17 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html const dispatch = createEventDispatcher(); + function isEqual(a: unknown, b: unknown): boolean { + if (typeof a === "number" && typeof b === "number") { + // round to .01 precision before comparing, + // so the values coming out of the UI match + // the originals + return isEqualLodash(Math.round(a * 100) / 100, Math.round(b * 100) / 100); + } else { + return isEqualLodash(a, b); + } + } + let modified: boolean; $: modified = !isEqual(value, defaultValue);