Closed lolcabanon closed 1 year ago
Ok put this one on hold there seems to be an issue...
I have an error TypeError: Cannot read properties of undefined (reading 'value')
unless I disable an re-enable the form.
After I disable an re-enable the form it seems to work all good tho...
Ok after a second checkup, it seems to work flawlessly as is with Budibase 2.5.2
.
Weird behaviour in my last comment only happen in version 2.4.31
(from that I cant test).
Should it really be ||
?
According to MDN about ??
:
The nullish coalescing (??) operator is a logical operator that returns its right-hand side operand when its left-hand side operand is null or undefined, and otherwise returns its left-hand side operand. [...] The nullish coalescing operator can be seen as a special case of the logical OR (||) operator. The latter returns the right-hand side operand if the left operand is any falsy value, not only null or undefined. In other words, if you use || to provide some default value to another variable foo, you may encounter unexpected behaviors if you consider some falsy values as usable (e.g., '' or 0).
I think if fieldState.disabled
is false
it should return false indeed. But if either fieldState
or fieldState.disabled
are undefined
it should then return disabled
(local variable defaulting to false
).
And by adding ?.
it is safe to test as fieldState?.disabled
will return undefined
if fieldState
or fieldState.disabled
are null
or undefined
.
Field will be disabled if the containing form is disabled.