Issue with duplicate values in Inputs.table()

Hey, there. I’ve found an issue specifically with the Table input native to Observable. If I am visualizing an array of objects via Inputs.table() with duplicate values, such as…

array = ["a", "a", "b" ,"c", "d", "d"]

And I pass to the value option the following…

value: array.slice(1,3)

I would expect to see the “a”, “b”, and “c” as rows selected in the table. Instead, I’m seeing “a”, “a”, “b”, and “c” selected. I have the same issue if the slice range involves either “d” value—clearly if I’m trying to preselect any value in the array that has duplicates, it selects all of those duplicate values. Sometimes I want more than one of them, others just an individual.

Any advice on how to work around this?

Inputs.table is designed to work with objects and matches values via a Set. Mapping your array values to e.g. [{value: "a"}, ...] (or even [["a"], ...]) should do the trick.

Thanks for jumping in. I made various attempts at mapping the array values like you suggested, but kept having issues getting the table to preselect anything in that format. Claude gave me another idea that ended up being easier—I had the notebook add another property with a unique number to each object being pulled into the table (“UID”), and then I was able to pass an array with specific row numbers, because they weren’t technically duplicate objects anymore.

Were you trying to map the values while you pass them to Inputs.table? As mentioned, Inputs.table uses a Set to match them, which means they are compared by reference, not shape.