You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This affects production (v0.5.3), as well as current develop.
To Reproduce
Steps to reproduce the behavior:
Existing performer with (for example) height set to 170 cm.
Make an edit to remove the height, and modify (change/add, but not delete) at least one other field.
Click to update the edit.
Height is silently restored to the form field.
When the update is submitted, the deleted value is restored to the edit.
This is applicable to at least height and disambiguation, but likely others, and on other entities too.
Expected behavior
Deleted fields in an edit to carry over when updating the edit.
Additional context
This feels like a repeat issue.
As far as I can tell, null denotes an empty value and undefined denotes omitted value (field was not provided, ignore).
However, it seems the code uses ?? (Nullish coalescing) and ||,
which means both values are treated the same - as ignored, so the next value in the chain is applied.
I'm not sure what the best fix is, but the simplest approach I could think of,
was to replace ?? with filtering to the first value that !== undefined in order.
For example,
height: [initial?.height,performer?.height].find((v)=>v!==undefined),// handling of height shouldn't be any different from disambiguation.// if empty strings exist in the chain they should probably be converted to null.
Probably in a function instead (and maybe a loop instead of Array.find()).
This type of solution may have current and/or future consequences with regard to field merges, as part of merging entities.
Currently, at least for merging performer - the initial prop to only used to provide the combined aliases and images fields.
This affects production (v0.5.3), as well as current develop.
To Reproduce
Steps to reproduce the behavior:
When the update is submitted, the deleted value is restored to the edit.
This is applicable to at least height and disambiguation, but likely others, and on other entities too.
Expected behavior
Deleted fields in an edit to carry over when updating the edit.
Additional context
This feels like a repeat issue.
As far as I can tell,
null
denotes an empty value andundefined
denotes omitted value (field was not provided, ignore).However, it seems the code uses
??
(Nullish coalescing) and||
,which means both values are treated the same - as ignored, so the next value in the chain is applied.
stash-box/frontend/src/pages/performers/performerForm/PerformerForm.tsx
Line 155 in 45ce233
stash-box/frontend/src/pages/performers/performerForm/PerformerForm.tsx
Line 168 in 45ce233
Potential solution
I'm not sure what the best fix is, but the simplest approach I could think of,
was to replace
??
with filtering to the first value that!== undefined
in order.For example,
Probably in a function instead (and maybe a loop instead of
Array.find()
).This type of solution may have current and/or future consequences with regard to field merges, as part of merging entities.
Currently, at least for merging performer - the
initial
prop to only used to provide the combinedaliases
andimages
fields.stash-box/frontend/src/pages/performers/PerformerMerge.tsx
Lines 166 to 169 in 45ce233
The text was updated successfully, but these errors were encountered: