react-postprocessing icon indicating copy to clipboard operation
react-postprocessing copied to clipboard

perf(Select): fix update loop

Open donalffons opened this issue 2 years ago • 3 comments

See #236 for additional details

Would be great to hear your feedback on this. This code

const changed = (current.length !== api.selected.length) ? true : !current.every(o => api.selected.includes(o))

is only correct if there are no duplicates in any of the two arrays (otherwise, they would have to be de-duped first) - but I believe that is the case here.

donalffons avatar Aug 12 '23 11:08 donalffons

Hmm after testing this further, I realized that this doesn't work in the case of

<Canvas>
  <Selection>
    <Select enabled>
      <Box name="box" />
    </Select>
    <Select enabled={false}>
    </Select>
  </Selection>
</Canvas>

I will look into this some more...

donalffons avatar Aug 12 '23 12:08 donalffons

I've played with this a bit more and I believe this fix is now working as intended.

donalffons avatar Aug 13 '23 09:08 donalffons

is it ready to go in? did you notice any adverse effects on older boxes?

drcmda avatar Aug 18 '23 10:08 drcmda