Skip to content

Commit

Permalink
fix: true-only checkbox lastSynced comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
Birkbjo committed Sep 25, 2022
1 parent d36c226 commit f15bbfb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/data-workspace/inputs/true-only-checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export const TrueOnlyCheckbox = ({
{
onSuccess: () => {
form.mutators.setFieldData(fieldname, {
lastSyncedValue: value,
// value will be formatted to boolean, so keep same format
// '' becomes false
lastSyncedValue: !!value,
})
},
}
Expand All @@ -43,7 +45,9 @@ export const TrueOnlyCheckbox = ({
const handleBlur = () => {
// For 'True only', can only send 'true' (or '1') or ''
const value = input.checked ? 'true' : ''
if (valid && value !== data.lastSyncedValue) {
const lastVal = data.lastSyncedValue ? 'true' : ''

if (valid && value !== lastVal) {
syncData(value)
}
}
Expand Down

0 comments on commit f15bbfb

Please sign in to comment.