I have a table with contents that get updated when a user presses a button. Starting off, the first table row should be selected (only one selection is allowed). On subsequent table updates, I would like to preserve the user’s selection, if the row still exists, or revert to the first table row.
I found here that in Observable notebooks this can be done using ‘this’. In the framework how can the previous state of a table input be accessed?
Now if the items in the array are not the exact same object from one selection to the next, you could fix the second issue by finding another mean to test if they correspond to the same individual (typically, by comparing their id). For example instead of items.find((d) => d === state.individual) we could say:
only the code block that declares a top-level variable can define it or assign to it
I thought it meant that state.individual = individual in a cell different from the defining one would cause an error. Instead, I tried to apply the mutables pattern but I run into scope problems.
As you said, it would be great if we knew the equivalent of this in Framework.