Copilot commented on code in PR #43150:
URL: https://github.com/apache/superset/pull/43150#discussion_r3785872140
##########
superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx:
##########
@@ -103,6 +103,44 @@ const sortTypes = {
alphanumeric: sortAlphanumericCaseInsensitive,
};
+// Prefer a stable identifier from original row data; otherwise use a
deterministic
+// concatenation of visible values (keys sorted so column order changes are
detected).
+function stableRowKey<D extends object>(r: Row<D>): string {
+ const orig = r.original as Record<string, unknown> | undefined;
+ if (orig) {
+ const idLike =
+ (orig as any).id ??
+ (orig as any).ID ??
+ (orig as any).key ??
+ (orig as any).uuid;
+ if (idLike != null) return String(idLike);
Review Comment:
`stableRowKey` uses several `(orig as any)` casts to probe common id fields.
Since `orig` is already a `Record<string, unknown>`, you can read these
properties without `any` and keep the function fully type-safe.
##########
superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx:
##########
@@ -103,6 +103,44 @@ const sortTypes = {
alphanumeric: sortAlphanumericCaseInsensitive,
};
+// Prefer a stable identifier from original row data; otherwise use a
deterministic
+// concatenation of visible values (keys sorted so column order changes are
detected).
Review Comment:
The comment says keys are sorted so column order changes are detected, but
sorting keys actually makes the derived key independent of column order. This
is misleading for future maintenance; update the wording to reflect that
sorting enforces deterministic ordering / stability across column-order changes.
This issue also appears on line 119 of the same file.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]