Skip to content
Permalink
Browse files

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
  • Loading branch information...
rickhanlonii authored and facebook-github-bot committed May 16, 2019
1 parent fb41a83 commit 7927437a6d5d63de2424d43d58085291c1067091
Showing with 3 additions and 3 deletions.
  1. +1 −1 Libraries/Components/Slider/SliderSchema.js
  2. +1 −1 React/Views/RCTSlider.h
  3. +1 −1 React/Views/RCTSliderManager.m
@@ -51,7 +51,7 @@ const SliderSchema: SchemaType = {
{
name: 'onSlidingComplete',
optional: true,
bubblingType: 'bubble',
bubblingType: 'direct',
typeAnnotation: {
type: 'EventTypeAnnotation',
argument: {
@@ -12,7 +12,7 @@
@interface RCTSlider : UISlider

@property (nonatomic, copy) RCTBubblingEventBlock onValueChange;
@property (nonatomic, copy) RCTBubblingEventBlock onSlidingComplete;
@property (nonatomic, copy) RCTDirectEventBlock onSlidingComplete;

@property (nonatomic, assign) float step;
@property (nonatomic, assign) float lastValue;
@@ -82,7 +82,7 @@ - (void)sliderTouchEnd:(RCTSlider *)sender
RCT_EXPORT_VIEW_PROPERTY(minimumTrackTintColor, UIColor);
RCT_EXPORT_VIEW_PROPERTY(maximumTrackTintColor, UIColor);
RCT_EXPORT_VIEW_PROPERTY(onValueChange, RCTBubblingEventBlock);
RCT_EXPORT_VIEW_PROPERTY(onSlidingComplete, RCTBubblingEventBlock);
RCT_EXPORT_VIEW_PROPERTY(onSlidingComplete, RCTDirectEventBlock);
RCT_EXPORT_VIEW_PROPERTY(thumbTintColor, UIColor);
RCT_EXPORT_VIEW_PROPERTY(thumbImage, UIImage);
RCT_CUSTOM_VIEW_PROPERTY(disabled, BOOL, RCTSlider)

0 comments on commit 7927437

Please sign in to comment.
You can’t perform that action at this time.