[WC-3322]: Fix slider decimal places formatting#2220
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
4e14487 to
945997f
Compare
This comment was marked as outdated.
This comment was marked as outdated.
945997f to
98f491a
Compare
AI Code Review
What was reviewed
Skipped (out of scope): CI checks could not be fetched — verify green before merge. Findings
|
Pull request type
Bug fix (non-breaking change which fixes an issue)
Description
When
decimalPlacesis configured on the Slider widget, displayed values were silently stripping trailing zeros:10.00rendered as10,9.20rendered as9.2Root causes:
marks.ts—parseFloat(value.toFixed(n)).toString()round-tripped through a number, discarding trailing zeros. Fixed by keeping thetoFixedstring directly as the label and usingparseFloatonly for the numeric key.createHandleRender.tsx— tooltip overlay receivedrestProps.value(raw RC Slider number). Fixed by adding adecimalPlacesparameter and applying.toFixed(decimalPlaces)before passing to the overlay.Files changed:
src/utils/marks.ts— fix label generationsrc/utils/createHandleRender.tsx— accept and applydecimalPlacessrc/components/Container.tsx— passdecimalPlacestocreateHandleRendersrc/utils/__tests__/marks.spec.ts— new unit testssrc/utils/__tests__/createHandleRender.spec.tsx— new unit testsWhat should be covered while testing?
decimalPlaces = 2andNumber of markers > 0.0.00,5.00,10.00— not0,5,10.10.00, not10.9.50.decimalPlaces = 0and verify no change in existing behavior (labels and tooltip show integers without decimal point).