twenty icon indicating copy to clipboard operation
twenty copied to clipboard

Fix record position calculation

Open FelixMalfait opened this issue 9 months ago • 0 comments

In record-position.factory.ts we currently have:

    return (
      (value === 'first'
        ? records[0]?.position / 2
        : records[0]?.position + 1) || 1
    );

That's an issue because if we use first 20 times in a row then we'll reach the limit of float precision.

We should probably instead allow negative numbers, and when someone passes "last" then do -1.

We should only use "/2" across the app in the rarest occurence when we want to insert a record between 2 given records.

Also, once that change is done we should make sure the default param when creating a record is "first" and not "last". That way the records created through the API will show up at the top which would be consistent with what we do in the UI when creating a new record with "+"

FelixMalfait avatar May 15 '24 14:05 FelixMalfait