Skip to content

Conversation

@mikolajwilczek
Copy link

Fixes #743

Summary:

  • Fix step marker alignment on web platform edges
  • Pass thumbSize prop to StepsIndicator component
  • Use actual thumbSize value instead of hardcoded constant
  • Add WebProps type for proper TypeScript typing

Test Plan:

  • Verified the change only affects the web platform - native platforms (iOS/Android) remain unchanged
  • Added web example with step numbers to demonstrate the fix
  • Tested step marker alignment at left edge, center, and right edge positions - all markers now align correctly with thumb positions
  • Tested with default and custom thumbSize values on web - alignment works correctly when thumbSize is smaller than the gap between steps
  • Regression tested on iOS, Android, and web (Safari and Chrome) - all existing examples continue to work
Screenshot 2025-12-18 at 20 12 13

- Pass thumbSize prop to StepsIndicator component
- Use actual thumbSize value instead of hardcoded constant
- Add WebProps type for proper TypeScript typing
- Fix step marker alignment on web platform edges

Fixes callstack#743
Copy link
Member

@BartoszKlonowski BartoszKlonowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is indeed the correct fix for the issue, thank you very much for the work, @mikolajwilczek 💪
Implementation wise it's good to go already, I have only one, however major, ask regarding the thumbSize prop, and after that it's good to be merged.

| `maximumTrackImage` | Assigns a maximum track image. Only static images are supported. The leftmost pixel of the image will be stretched to fill the track. | Image<br/>.propTypes<br/>.source | iOS |
| `minimumTrackImage` | Assigns a minimum track image. Only static images are supported. The rightmost pixel of the image will be stretched to fill the track. | Image<br/>.propTypes<br/>.source | iOS |
| `thumbImage` | Sets an image for the thumb. Only static images are supported. Needs to be a URI of a local or network image; base64-encoded SVG is not supported. | Image<br/>.propTypes<br/>.source | |
| `thumbSize` | Define the size of the thumb. Only for web<br/>Default value is 20px. | number | web |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to add this as a new prop - doing this will bring a lot of confusion for users.
Devs been asking for such customization for a long time now, expecting a possibility to actually increase the visible size of the thumb. What we have here, instead, is the "under the hood" layout width of the thumb that we reserve for the proper alignment when rendering Slider with steps number.
Let's remove this thumbSize prop from where relevant (README, Slider.tsx) and let's make it a const just for the implementation detail purpose.

: constants.STEP_NUMBER_TEXT_FONT_BIG,
};
}, [options.length]);
const platformDependentStyles = useMemo(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const platformDependentStyles = useMemo(() => {
const platformDependentStyles = useMemo(() => {

}
: styles.stepIndicatorElement,
};
}, [sliderWidth, thumbSize]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}, [sliderWidth, thumbSize]);
}, [sliderWidth, thumbSize]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Web: Step markers don't align with thumb positions

2 participants