sadpandajoe commented on code in PR #45241:
URL: https://github.com/apache/superset/pull/45241#discussion_r4262334144


##########
superset-frontend/packages/superset-ui-core/src/number-format/NumberFormatterRegistry.ts:
##########
@@ -36,23 +36,33 @@ export default class NumberFormatterRegistry extends 
RegistryWithDefaultKey<
       overwritePolicy: OverwritePolicy.Warn,
     });
 
-    this.registerValue(
-      NumberFormats.SMART_NUMBER,
-      createSmartNumberFormatter(),
-    );
-    this.registerValue(
-      NumberFormats.SMART_NUMBER_SIGNED,
-      createSmartNumberFormatter({ signed: true }),
-    );
-    this.setDefaultKey(NumberFormats.SMART_NUMBER);
     this.d3Format = DEFAULT_D3_FORMAT;
+    this.registerSmartNumberFormatters();
+    this.setDefaultKey(NumberFormats.SMART_NUMBER);
   }
 
   setD3Format(d3Format: Partial<FormatLocaleDefinition>) {
     this.d3Format = { ...DEFAULT_D3_FORMAT, ...d3Format };
+    // The adaptive formatters are registered up front, so they would keep the
+    // locale they were built with; rebuild them to follow the new one.
+    this.remove(NumberFormats.SMART_NUMBER).remove(
+      NumberFormats.SMART_NUMBER_SIGNED,
+    );
+    this.registerSmartNumberFormatters();
     return this;
   }
 
+  private registerSmartNumberFormatters() {
+    this.registerValue(
+      NumberFormats.SMART_NUMBER,
+      createSmartNumberFormatter({ locale: this.d3Format }),

Review Comment:
   With the adaptive formatter now localized, anything that parses its output 
back into a number will see a different value when `D3_FORMAT.decimal` is `,`. 
For example, the AG Grid table's `filterValueGetter` runs `parseFloat` on the 
formatted string, so a value of `0.25` on a column left on Adaptive formatting 
goes from `"0.25"` (0.25) to `"0,25"` (0), and a "greater than 0.1" column 
filter then drops that row. Should the AG Grid filter getter (and any similar 
consumer) read the raw value rather than the formatted text, or is it fine to 
leave this as a follow-up?



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