Compare commits

...

1 Commits

Author SHA1 Message Date
Claire Chabas 35061b8cd6 Make tables sorting deterministic 2026-01-21 12:54:29 +00:00
@@ -18,9 +18,17 @@ export function Table(props: BlockProps<DocumentBlockTable>) {
const { block, ancestorBlocks, document } = props;
const isOffscreen = isBlockOffscreen({ block, ancestorBlocks, document });
const records: TableRecordKV[] = Object.entries(block.data.records).sort((a, b) => {
return a[1].orderIndex.localeCompare(b[1].orderIndex);
});
const records: TableRecordKV[] = Object.entries(block.data.records).sort(
([aKey, aValue], [bKey, bValue]) => {
const orderComparison = aValue.orderIndex.localeCompare(bValue.orderIndex);
if (orderComparison !== 0) {
return orderComparison;
}
return aKey.localeCompare(bKey);
}
);
switch (block.data.view.type) {
case 'cards':