Skip to content

Commit 7927437

Browse files
rickhanloniifacebook-github-bot
authored andcommitted
Switch Slider onSlidingComplete event to a non-bubbling event on iOS to match Android
Summary: ## Overview This diff switches the RCTSlider onSlidingComplete event on iOS from a bubbling event to a direct (non-bubbling) event to match the non-bubbling type on android. Note that in this case these seems like a bug. I will still explain the motivation and reasoning as this will come up in future diffs. ## Changelog [Slider][BREAKING] Switch Slider onSlidingComplete event to a non-bubbling event on iOS to match Android ## Motivation: The motivation here is that when we codgen the view configs, we'll need to unify all of the events and props across platforms for components that have the same name on iOS and Android. In this case, the view configs (below) conflict for onSlidingComplete. On iOS this is under bubblingEventTypes, on Android this is under directEventTypes. We have code [here](https://fburl.com/3s1dahm2) in the react native renderer which ensures an event is not listed as both. ``` // iOS const SliderViewConfig = { bubblingEventTypes: { onSlidingComplete: { phasedRegistrationNames: { captured: 'onChangeCapture', bubbled: 'onChange' } } }, directEventTypes: { // None }, validAttributes: { // ... } }; ``` ``` // Android const SliderViewConfig = { bubblingEventTypes: { // None }, directEventTypes: { onSlidingComplete: { registrationName: 'onEventDirect' } }, validAttributes: { // ... } }; ``` ## Solutions There are three solutions to this issue: 1. Don't generate view configs 2. Rename the component on one platform 3. Make a breaking change in the event behavior on one platform to make it consistent across both platforms Here we've chosen option #3 Reviewed By: TheSavior Differential Revision: D15322304 fbshipit-source-id: ff1ab86efe9e2bc50fd3f7619e6760ab5c1c5090
1 parent fb41a83 commit 7927437

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

Libraries/Components/Slider/SliderSchema.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const SliderSchema: SchemaType = {
5151
{
5252
name: 'onSlidingComplete',
5353
optional: true,
54-
bubblingType: 'bubble',
54+
bubblingType: 'direct',
5555
typeAnnotation: {
5656
type: 'EventTypeAnnotation',
5757
argument: {

React/Views/RCTSlider.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@interface RCTSlider : UISlider
1313

1414
@property (nonatomic, copy) RCTBubblingEventBlock onValueChange;
15-
@property (nonatomic, copy) RCTBubblingEventBlock onSlidingComplete;
15+
@property (nonatomic, copy) RCTDirectEventBlock onSlidingComplete;
1616

1717
@property (nonatomic, assign) float step;
1818
@property (nonatomic, assign) float lastValue;

React/Views/RCTSliderManager.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ - (void)sliderTouchEnd:(RCTSlider *)sender
8282
RCT_EXPORT_VIEW_PROPERTY(minimumTrackTintColor, UIColor);
8383
RCT_EXPORT_VIEW_PROPERTY(maximumTrackTintColor, UIColor);
8484
RCT_EXPORT_VIEW_PROPERTY(onValueChange, RCTBubblingEventBlock);
85-
RCT_EXPORT_VIEW_PROPERTY(onSlidingComplete, RCTBubblingEventBlock);
85+
RCT_EXPORT_VIEW_PROPERTY(onSlidingComplete, RCTDirectEventBlock);
8686
RCT_EXPORT_VIEW_PROPERTY(thumbTintColor, UIColor);
8787
RCT_EXPORT_VIEW_PROPERTY(thumbImage, UIImage);
8888
RCT_CUSTOM_VIEW_PROPERTY(disabled, BOOL, RCTSlider)

0 commit comments

Comments
 (0)