7487 commented on code in PR #39658:
URL: https://github.com/apache/superset/pull/39658#discussion_r3891731015


##########
superset-frontend/plugins/plugin-chart-table/src/utils/formatValue.ts:
##########
@@ -50,11 +50,15 @@ function formatValue(
     return [false, 'N/A'];
   }
   if (formatter) {
-    // If formatter is a CurrencyFormatter, pass row context for AUTO mode
-    if (formatter instanceof CurrencyFormatter) {
-      return [false, formatter(value as number, rowData, currencyColumn)];
+    try {
+      // If formatter is a CurrencyFormatter, pass row context for AUTO mode
+      if (formatter instanceof CurrencyFormatter) {
+        return [false, formatter(value as number, rowData, currencyColumn)];
+      }
+      return [false, formatter(value as number)];
+    } catch (e) {
+      return [false, String(value)];
     }

Review Comment:
   Added a `logging.warn` in the catch so formatter failures are no longer 
silent (cd6c5d6). On the sanitize point: the fallback returns `[false, 
String(value)]` — the `false` flag means the cell is rendered as plain text 
(React-escaped), not through `dangerouslySetInnerHTML`, so it never bypasses 
the `isProbablyHTML`/`sanitizeHtml` guard. Also added unit tests covering the 
fallback for both formatter paths.



##########
superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx:
##########
@@ -243,6 +243,13 @@ export default typedMemo(function DataTable<D extends 
object>({
     },
     ...tableHooks,
   );
+  // Clamp pageIndex when filtered data shrinks below current view (#31403)
+  if (data.length > 0 && pageCount > 0 && pageIndex >= pageCount) {
+    gotoPage(pageCount - 1);
+  } else if (pageCount === 0 && pageIndex !== 0) {
+    gotoPage(0);
+  }

Review Comment:
   Right — and this pagination clamp didn't belong in this PR in the first 
place (it duplicates #39661, which tracks that fix separately). Reverted it 
here in 7775ae1 so this PR stays scoped to the formatter fix.



-- 
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]

Reply via email to