Copilot commented on code in PR #45145:
URL: https://github.com/apache/superset/pull/45145#discussion_r4233520451


##########
superset-frontend/src/explore/components/controls/ColumnConfigControl/constants.tsx:
##########
@@ -46,17 +46,23 @@ export type SharedColumnConfigProp =
   | 'displayTypeIcon'
   | 'currencyFormat';
 
+const d3NumberFormatOptions: [string, string][] = [
+  ...D3_FORMAT_OPTIONS,
+  [',.0f', ',.0f (12,345)'],
+];
+
 const d3NumberFormat: ControlFormItemSpec<'Select'> = {
   allowNewOptions: true,
   controlType: 'Select',
   label: t('D3 format'),
   description: D3_FORMAT_DOCS,
-  options: D3_FORMAT_OPTIONS.map(option => ({
+  options: d3NumberFormatOptions.map(option => ({
     value: option[0],
     label: option[1],
   })),
   defaultValue: D3_FORMAT_OPTIONS[0][0],
   creatable: true,
+  tokenSeparators: ['\n', '\t', ';'],

Review Comment:
   Including `';'` as a token separator will break valid D3 format strings that 
use semicolons to separate positive/negative formats (e.g. `.2f;(.2f)`), 
because the input will be split into multiple tokens. Consider removing `';'` 
from `tokenSeparators` (and update the corresponding test), and rely on 
separators that cannot appear in a D3 specifier (e.g. newline/tab). Also, if 
users paste Windows newlines (`\\r\\n`), splitting only on `\\n` can leave a 
trailing `\\r` character in the token; consider handling `\\r` as well (either 
add `\\r` to separators or ensure tokens are trimmed/normalized).



##########
superset-frontend/src/explore/components/controls/ColumnConfigControl/constants.tsx:
##########
@@ -46,17 +46,23 @@ export type SharedColumnConfigProp =
   | 'displayTypeIcon'
   | 'currencyFormat';
 
+const d3NumberFormatOptions: [string, string][] = [
+  ...D3_FORMAT_OPTIONS,
+  [',.0f', ',.0f (12,345)'],
+];
+
 const d3NumberFormat: ControlFormItemSpec<'Select'> = {
   allowNewOptions: true,
   controlType: 'Select',
   label: t('D3 format'),
   description: D3_FORMAT_DOCS,
-  options: D3_FORMAT_OPTIONS.map(option => ({
+  options: d3NumberFormatOptions.map(option => ({
     value: option[0],
     label: option[1],
   })),
   defaultValue: D3_FORMAT_OPTIONS[0][0],

Review Comment:
   The control options are now derived from `d3NumberFormatOptions`, but 
`defaultValue` is still tied to `D3_FORMAT_OPTIONS`. To keep the default 
consistent with the rendered option list (and avoid drift if the source 
changes), consider deriving the default from `d3NumberFormatOptions[0][0]` 
instead.



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