Incorrect SingleSelect state transformer in MultiStageAboutWelcome
Categories
(Firefox :: Messaging System, defect, P3)
Tracking
()
People
(Reporter: aminomancer, Assigned: andrewt.tu)
Details
(Keywords: good-first-bug, Whiteboard: may-intern)
Attachments
(1 external file)
I stumbled on this, which I think is technically incorrect. it's fortunately not being reached because the only callers are passing a string, not a function.
strictly speaking, this is meant to be a transformer of the property labeled with singleSelectId. but the argument it's passing (prevState[currentScreen.id]) is the value for the parent object, up one level. so if it were reached, it would yield recursive references like:
{
SCREEN_1: {
SELECT_1: {
SELECT_1: {
...
}
}
}
}
because the value of SELECT_1 is set to the previous value of SCREEN_1, which is just SELECT_1's 'parent' object.
so what it should say instead of valueOrFn(prevState[currentScreen.id]) is valueOrFn(currentScreenSelections[singleSelectId]).
but this setter doesn't really need to accept a transformer function at all. that capability was mainly intended for the MultiSelect setter. I think the reasoning was that it would allow us to add a selected item to a map of already-selected items without wiping them or passing them every time. but SingleSelect only has one selected item, so it would never need to transform a previous state. so for simplicity's sake, it might be better to just change it from valueOrFn to just value and remove the function check entirely. that certainly makes this code more readable and less confusing!
| Reporter | ||
Updated•3 months ago
|
| Reporter | ||
Updated•3 months ago
|
Hi Meg, I'd like to take this task
Hi Andrew, thanks for offering to pick this up! Feel free to ping me if you need any support.
Description
•