You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by sb...@apache.org on 2026/10/09 23:39:58 UTC

(superset) branch master updated: fix(column-config): allow commas in D3 number formats (#45145)

This is an automated email from the ASF dual-hosted git repository.

SBIN2010 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new ab2c69f29cd fix(column-config): allow commas in D3 number formats (#45145)
ab2c69f29cd is described below

commit ab2c69f29cd0c47e91f73e51b0ff480c62f2b17b
Author: Rabuma A. Bekele <ia...@gmail.com>
AuthorDate: Sat Oct 10 01:39:51 2026 +0200

    fix(column-config): allow commas in D3 number formats (#45145)
---
 .../src/utils/D3Formatting.ts                      |  1 +
 .../ColumnConfigConstants.test.tsx                 | 25 +++++++++++-----------
 .../controls/ColumnConfigControl/constants.tsx     |  2 ++
 3 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/utils/D3Formatting.ts b/superset-frontend/packages/superset-ui-chart-controls/src/utils/D3Formatting.ts
index 2351cddc4ec..8a64e91ab4a 100644
--- a/superset-frontend/packages/superset-ui-chart-controls/src/utils/D3Formatting.ts
+++ b/superset-frontend/packages/superset-ui-chart-controls/src/utils/D3Formatting.ts
@@ -43,6 +43,7 @@ const d3Formatted: [string, string][] = [
   '.2%',
   '.3%',
   '.4r',
+  ',.0f',
   ',.1f',
   ',.2f',
   ',.3f',
diff --git a/superset-frontend/src/explore/components/controls/ColumnConfigControl/ColumnConfigConstants.test.tsx b/superset-frontend/src/explore/components/controls/ColumnConfigControl/ColumnConfigConstants.test.tsx
index dc6407c812f..75b04431ca0 100644
--- a/superset-frontend/src/explore/components/controls/ColumnConfigControl/ColumnConfigConstants.test.tsx
+++ b/superset-frontend/src/explore/components/controls/ColumnConfigControl/ColumnConfigConstants.test.tsx
@@ -19,21 +19,22 @@
 
 import { SHARED_COLUMN_CONFIG_PROPS } from './constants';
 
-test('should allow commas in D3 format inputs', () => {
+test('should include the comma-separated number format preset', () => {
   const { options } = SHARED_COLUMN_CONFIG_PROPS.d3NumberFormat;
-  const labels = (options ?? []).map((option: { label: unknown }) =>
-    String(option.label),
-  );
-  expect(labels.some((label: string) => label.includes(','))).toBe(true);
+
+  expect(options).toContainEqual({
+    value: ',.0f',
+    label: ',.0f (12345.432 => 12,345)',
+  });
 });
 
-test('should use defaults from Select token separators', () => {
-  expect(
-    Object.prototype.hasOwnProperty.call(
-      SHARED_COLUMN_CONFIG_PROPS.d3NumberFormat,
-      'tokenSeparators',
-    ),
-  ).toBe(false);
+test('should not treat commas as D3 format token separators', () => {
+  expect(SHARED_COLUMN_CONFIG_PROPS.d3NumberFormat.tokenSeparators).toEqual([
+    '\r\n',
+    '\n',
+    '\t',
+    ';',
+  ]);
 });
 
 test('d3NumberFormat and d3TimeFormat should allow free-text entry', () => {
diff --git a/superset-frontend/src/explore/components/controls/ColumnConfigControl/constants.tsx b/superset-frontend/src/explore/components/controls/ColumnConfigControl/constants.tsx
index 0e9265e5fa9..c01627a8fc1 100644
--- a/superset-frontend/src/explore/components/controls/ColumnConfigControl/constants.tsx
+++ b/superset-frontend/src/explore/components/controls/ColumnConfigControl/constants.tsx
@@ -57,6 +57,8 @@ const d3NumberFormat: ControlFormItemSpec<'Select'> = {
   })),
   defaultValue: D3_FORMAT_OPTIONS[0][0],
   creatable: true,
+  // Keep commas out of token separators because they are valid in D3 number formats.
+  tokenSeparators: ['\r\n', '\n', '\t', ';'],
   minWidth: '14em',
   debounceDelay: 500,
 };