mirakour opened a new pull request, #41098:
URL: https://github.com/apache/superset/pull/41098

   ### Summary
   
   Fixes #36189
   
   When a table column uses a D3 percentage format (e.g. `.8%`), values smaller 
than 1 in absolute terms are incorrectly routed to the small-number formatter 
instead of the intended percentage formatter. Since percentage values are 
stored as decimals (0.05 = 5%), the existing `Math.abs(value) < 1` guard fires 
for every value in a percentage column.
   
   ### Changes
   
   **`formatValue.ts`**
   - Added `isPercentageFormat(formatString)` helper that returns `true` when 
the D3 format string ends with `%`
   - Added `!isPercentageFormat(config.d3NumberFormat)` to the 
`useSmallNumberFormatter` condition so percentage columns always use their 
intended formatter
   
   **`formatValue.test.ts`** (new file)
   - Tests for very small negative/positive percentage values
   - Tests that the raw value is no longer returned for small percentages
   - Tests that non-percentage small numbers still use the small-number 
formatter
   - Edge cases: null and undefined values
   
   ### Before / After
   
   | Value | Format | Before | After |
   |-------|--------|--------|-------|
   | `-0.00001229` | `.8%` | `-0.00001229` | `-0.00122900%` |
   | `0.0001` | `.8%` | `0.0001` | `0.01000000%` |
   | `0.0523` | `.2%` | `5.23%` | `5.23%` (unchanged) |
   
   ### Testing
   
   Added unit tests in `formatValue.test.ts` covering the bug scenario and edge 
cases.


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