Commit Graph

60 Commits

Author SHA1 Message Date
Valentin Shergin 072d2709df Introducing `-[RCTView reactAccessibleView]`
Summary:
Sometimes, when we implement some custom RN view, we have to proxy all accessible atributes directly to some subview which actually has accesible content. So, in other words, this allows bypass some axillary views in terms of accessibility.
Concreate example which this approach supposed to fix:
https://github.com/facebook/react-native/pull/14200/files#diff-e5f6b1386b7ba07fd887bca11ec828a4R208

Reviewed By: mmmulani

Differential Revision: D5143860

fbshipit-source-id: 6d7ce747f28e5a31d32c925b8ad8fd4b98ce1de1
2017-06-02 14:19:57 -07:00
Valentin Shergin e13b9c6e49 RCTTextField was spliited into two classes
Summary:
Motivation:
 * We maintain two different implementation of <TextInput> (multilined and singlelined), this change makes the implementations much similar which will help us to support and improve both of them in the (near) future;
 * We have to have separated RCTView-based container view for (TextField) to support sofisticated bordering and so on;
 * It opens to us possibility to unify UITextView and UITextField subclasses and remove code duplication across RCTTextView and RCTTextField;
 * Making things decoupled in general will allow us to fix existing bugs with events.

Reviewed By: mmmulani

Differential Revision: D5083010

fbshipit-source-id: 2f2d42c2244d2b39256c51480c1f16f4e3947c01
2017-05-29 16:01:11 -07:00
Valentin Shergin 48650226e8 Multiline <TextInput> was fixed to match layout logic of singlelined one
Summary: Now padding, border and intinsic sizes are computed same way as for singlelined text input.

Reviewed By: mmmulani

Differential Revision: D5075880

fbshipit-source-id: 1bc2fd479c13a003c717b1fc3d9c69f4639d4444
2017-05-29 16:01:09 -07:00
Valentin Shergin bac84ce207 BREAKING: Better TextInput: `contentSize` property was removed from `<TextInput>.onChange` event (Second attempt)
Summary:
`contentSize` was removed from both iOS and Android, tests was updated.
USE `onContentSizeChange` INSTEAD.

Why?
 * It always was a hack;
 * We already have dedicated event for it: `onContentSizeChange`;
 * `onChange` has nothing to do with layout actually;
 * We have to maintain `onChange` handler as fast and simple as possible, this feature complicates it a lot;
 * It was undocumented feature;
 * We already have native auto-expandable <TextInput>, so it illuminates 99% current use cases of this feature.

Reviewed By: mmmulani

Differential Revision: D4989881

fbshipit-source-id: 674bb98c89ada1fca7b3b20b304736b2a3b8304e
2017-05-28 20:16:04 -07:00
Valentin Shergin f73464851b Revert D4680300: [RN] BREAKING: Better TextInput: `contentSize` property was removed from `<TextInput>.onChange` event.
Differential Revision: D4680300

fbshipit-source-id: 20f7299c53cc54215fb333e97d7e11de087e303d
2017-05-01 21:15:44 -07:00
Valentin Shergin 99e24ecc67 BREAKING: Better TextInput: `contentSize` property was removed from `<TextInput>.onChange` event.
Summary:
`contentSize` was removed from both iOS and Android, tests was updated.
USE `onContentSizeChange` INSTEAD.

Why?
 * It always was a hack;
 * We already have dedicated event for it: `onContentSizeChange`;
 * `onChange` has nothing to do with layout actually;
 * We have to maintain `onChange` handler as fast and simple as possible, this feature complicates it a lot;
 * It was undocumented feature;
 * We already have native auto-expandable <TextInput>, so it illuminates 99% current use cases of this feature.

Reviewed By: mmmulani

Differential Revision: D4680300

fbshipit-source-id: 337836deef0767e5f26350f5a8ce73adb4146a02
2017-04-30 23:02:25 -07:00
Valentin Shergin bc1ea548d0 Better TextInput: Simplified focus/first-responder management on iOS
Summary:
Pair `reactWillMakeFirstResponder` and `reactDidMakeFirstResponder` was replaced with just `reactFocus` method
which is supposed to incapsulate all "focus" and "focus-later-if-needed" functionality.

Reviewed By: mmmulani

Differential Revision: D4664626

fbshipit-source-id: 8d3b7935ca26d32ba1d1826a585cce0396fcc885
2017-04-03 15:16:16 -07:00
Valentin Shergin b53d76efb7 Better TextInput: RCTUITextView was decoupled in separate file and now handles placeholder feature
Reviewed By: mmmulani

Differential Revision: D4663151

fbshipit-source-id: ce57ca4bebf4676df2ae5e586a1b175ec2aac760
2017-03-20 00:02:58 -07:00
Valentin Shergin 1b013cd30c Better TextInput: Fixing multiline <TextInput> insets and prepare for auto-expanding feature
Summary:
Several things:
 * The mess with insets was fixed. Previously we tried to compensate the insets difference with `UITextField` by adjusting `textContainerInset` property, moreover we delegated negative part of this compensation to the view inset. That was terrible because it breaks `contentSize` computation, complicates whole insets consept, complicates everything; it just was not right. Now we are fixing the top and left inset differences in different places. We disable left and right 5pt margin by setting `_textView.textContainer.lineFragmentPadding = 0` and we introduce top 5px inset as a DEFAULT value for top inset for common multiline <TextInput> (this value can be easilly overwritten in Javascript).
 * Internal layout and contentSize computations were unified and simplified.
 * Now we report `intrinsicContentSize` value to Yoga, one step before auto-expandable TextInput.

Depends on D4640207.

Reviewed By: mmmulani

Differential Revision: D4645921

fbshipit-source-id: da5988ebac50be967caecd71e780c014f6eb257a
2017-03-20 00:02:55 -07:00
Valentin Shergin 3acafd1f3d Better TextInput: Removed redundant UIScrollView from RCTTextView
Reviewed By: mmmulani

Differential Revision: D4640207

fbshipit-source-id: 01fc65b0212ad6baef500625679dab5e99da9db5
2017-03-20 00:02:54 -07:00
Valentin Shergin 4040e89ac5 `<TextView>.onContentSizeChange` now fires on ANY content changing circumstances
Reviewed By: blairvanderhoof

Differential Revision: D4625916

fbshipit-source-id: 80191a07edaf404a70a7571ada2d849619407bda
2017-03-06 16:35:08 -08:00
Valentin Shergin 9a9ecea873 Fixed calling TextInput.onChange() on applying autocorrection (iOS)
Reviewed By: javache

Differential Revision: D4444428

fbshipit-source-id: 1b107e79307dedad43bed4ba6f456b4988904764
2017-01-24 16:58:27 -08:00
Adam Comella 0e55f5b26d iOS: Introduce spellCheck prop to TextInput
Summary:
This exposes iOS's spellCheckingType functionality to JavaScript. The native functionality is a three state enum. It gets exposed to JavaScript as a boolean. The initial value and JS null map to the third state.

An alternative design for this API would have been to expose a three state enum to JavaScript:
  - "on" which maps to UITextSpellCheckingTypeYes
  - "off" which maps to UITextSpellCheckingTypeNo
  - "auto" (default) which maps to UITextSpellCheckingTypeDefault

For consistency, I decided to use the same API design as spellCheck. We don't have many options for fixing spellCheck in #11055 without introducing a breaking change.

**Test plan (required)**

Verified that switching `spellCheck` between `true`, `false`, and `null` all work correctly in single line and multiline `TextInputs`.
Closes https://github.com/facebook/react-native/pull/11056

Differential Revision: D4232802

Pulled By: javache

fbshipit-source-id: 79e03307fa6a30a169f7e2fd0ec5ac826663e7c1
2016-11-25 04:28:28 -08:00
Pieter De Baets e1577df1fd Move all header imports to "<React/..>"
Summary:
To make React Native play nicely with our internal build infrastructure we need to properly namespace all of our header includes.

Where previously you could do `#import "RCTBridge.h"`, you must now write this as `#import <React/RCTBridge.h>`. If your xcode project still has a custom header include path, both variants will likely continue to work, but for new projects, we're defaulting the header include path to `$(BUILT_PRODUCTS_DIR)/usr/local/include`, where the React and CSSLayout targets will copy a subset of headers too. To make Xcode copy headers phase work properly, you may need to add React as an explicit dependency to your app's scheme and disable "parallelize build".

Reviewed By: mmmulani

Differential Revision: D4213120

fbshipit-source-id: 84a32a4b250c27699e6795f43584f13d594a9a82
2016-11-23 07:58:39 -08:00
Adam Comella 8016d838be iOS: Fix autoCorrect doesn't revert to initial state
Summary:
There's an inconsistency in autoCorrect's default state:
  - If you don't specify a value for autoCorrect, it defaults to on.
  - If you specify true/false for autoCorrect and later specify null, autoCorrect turns off. It should have reverted to its initial state of on.

The reason for this discrepancy is that autoCorrect is exposed to JS as a boolean but it is actually an enum with three states in native:
  - UITextAutocorrectionTypeDefault (the default value)
  - UITextAutocorrectionTypeYes
  - UITextAutocorrectionTypeNo

This is fixed by explicitly mapping JS null to UITextAutocorrectionTypeDefault.

**Test plan (required)**

Verified that switching `autoCorrect` between `true`, `false`, and `null` all work correctly in single line and multiline `TextInputs`.

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/11055

Differential Revision: D4226419

Pulled By: javache

fbshipit-source-id: e3e5769a3aa537f00fb56ca4ae622ff4213481c5
2016-11-23 05:43:35 -08:00
Adam Comella c609aee733 iOS: Add onScroll event to TextInput
Summary:
Corresponding Android PR: https://github.com/facebook/react-native/pull/11001

This adds an onScroll event to TextInput which is useful when a multiline TextInput has so much content that it is scrollable.

**Test plan (required)**

Verified the event works properly in a test app. Also, my team uses this event in our app.

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/11002

Differential Revision: D4203565

Pulled By: ericvicenti

fbshipit-source-id: 7cb5e10325c3b03c6b395cce0f1bacb0528db40a
2016-11-22 11:58:37 -08:00
Douglas Lowder d368ebfab2 Apple TV support 1: existing Objective C code should compile for tvOS
Summary:
First commit for Apple TV support: changes to existing Objective-C code so that it will compile correctly for tvOS.
Closes https://github.com/facebook/react-native/pull/9649

Differential Revision: D3916021

Pulled By: javache

fbshipit-source-id: 34acc9daf3efff835ffe38c43ba5d4098a02c830
2016-09-27 06:28:33 -07:00
Janic Duplessis f0a3c56048 Add TextInput controlled selection prop on iOS
Summary:
This adds support for a controlled `selection` prop on `TextInput` on iOS (Android PR coming soon). This is based on the work by ehd in #2668 which hasn't been updated for a while, kept the original commit and worked on fixing what was missing based on the feedback in the original PR.

What I changed is:
- Make the prop properly controlled by JS
- Add a RCTTextSelection class to map the JS object into and the corresponding RCTConvert category
- Make sure the selection change event is properly triggered when the input is focused
- Cleanup setSelection
- Changed TextInput to use function refs to appease the linter

** Test plan **
Tested using the TextInput selection example in UIExplorer on iOS.
Also tested that it doesn't break Android.
Closes https://github.com/facebook/react-native/pull/8958

Differential Revision: D3771229

Pulled By: javache

fbshipit-source-id: b8ede46b97fb3faf3061bb2dac102160c4b20ce7
2016-08-25 17:28:37 -07:00
Pieter De Baets 23e087fc26 Fix TextInput stack overflow when pasting text in multiline input with maxlength
Summary: When pasting text longer than maxlenght, the textDidChange: call we did would end calling back into textView:shouldChange: because we saw an unexpected multi-character change. Since this is an expected mutation, update predictedText appropriately.

Reviewed By: majak

Differential Revision: D3561524

fbshipit-source-id: 07bb78d830ccfa3aed6ee274dc30adeadce9e1f8
2016-07-14 07:43:32 -07:00
Janic Duplessis 2537157d99 Implement TextInput onContentSizeChange
Summary:
This adds proper support for tracking a TextInput content size as discussed in #6552 by adding a new callback that is called every time the content size changes including when first rendering the view.

Some points that are up for discussion are what do we want to do with the onChange callback as I don't see any use left for it now that we can track text change in onChangeText and size changes in onContentSizeChange. Also a bit off topic but should we consider renaming onChangeText to onTextChange to keep the naming more consistent (see [this naming justification](https://twitter.com/notbrent/status/709445076850597888)).

This is split in 2 commits for easier review, one for iOS and one for android.

The iOS implementation simply checks if the content size has changed everytime we update it and fire the callback, the only small issue was that the content size had several different values on initial render so I added a check to not fire events before the layoutSubviews where at this point the value is g
Closes https://github.com/facebook/react-native/pull/8457

Differential Revision: D3528202

Pulled By: dmmiller

fbshipit-source-id: fefe83f10cc5bfde1f5937c48c88b10408e58d9d
2016-07-07 09:00:01 -07:00
Pieter De Baets d29e8ae0ca Implement onTextInput events for RCTTextView
Reviewed By: blairvanderhoof

Differential Revision: D3475581

fbshipit-source-id: df2fb8e1e898dfe6af455db0f96ecb23b4aa0721
2016-06-24 06:43:37 -07:00
Pieter De Baets cc959273da Fix multi-character TextInput
Reviewed By: hnery

Differential Revision: D3457105

fbshipit-source-id: dcb364123ed82842d4fb2dee9108f2805249a8f9
2016-06-23 03:58:33 -07:00
Dave 97c483ec29 adds textAlignment to placeholder to match textViews alignment (for m…
Summary:
Submitting PR for adding textAlignment to the placeholder of textView so that it matches the alignment of the actual value text
Closes https://github.com/facebook/react-native/pull/7429

Differential Revision: D3422007

fbshipit-source-id: e255c2d86dbaa0e197328a56ec81cbab2735c53d
2016-06-10 20:28:23 -07:00
Nick Lockwood 79dcbc7b29 Fix unit tests
Reviewed By: bestander

Differential Revision: D3398431

fbshipit-source-id: 37561bea78c933673595625530cf083c85c3fbbd
2016-06-07 08:43:22 -07:00
Nick Lockwood 46c02b6ae5 Refactored subview management
Summary:
This diff refactors the view update process into two stages:

1. The `reactSubviews` array is set, whose order matches the order of the JS components and shadowView components, as specified by the UIManager.
2. The `didUpdateReactSubviews` method is called, which actually inserts the reactSubviews into the view hierarchy.

This simplifies a lot of the hacks we had for special-case treatment of subviews: In many cases we don't want to actually insert `reactSubviews` into the parentView, and we had a bunch of component-specific solutions for that (typically overriding all of the reactSubviews methods to store views in an array). Now, we can simply override the `didUpdateReactSubviews` method for those views to do nothing, or do something different.

Reviewed By: wwjholmes

Differential Revision: D3396594

fbshipit-source-id: 92fc56fd31db0cfc66aac3d1634a4d4ae3903085
2016-06-07 00:14:39 -07:00
Nick Lockwood 93c7a93de9 Reverted commit D3392214
Reviewed By: javache

Differential Revision: D3392214

fbshipit-source-id: 4136c8b0eb160f4b245df2e4b5d67d00efd7b1a7
2016-06-06 16:28:21 -07:00
Ben Nham 1fce89176b Explicitly set default background color in RCTTextView
Summary:
RCTShadowText currently explicitly defaults to black text color:

https://github.com/facebook/react-native/blob/d46ac11/Libraries/Text/RCTShadowText.m#L204

However, the UITextView used by RCTTextInput doesn't explicitly default to black text color.

This causes issues when RCTTextInput is in rich text editing mode (i.e. when the <TextInput> element uses child <Text> nodes to provide extra styling info) and the client doesn't provide us with any explicit color info. In this case, the following series of badness occurs:

1. -[UITextView attributedText] will return an attributed string without the NSColor property set.
2. -[RCTShadowText attributedString] will return an attributed string with NSColor equal to blackColor.
3. The `[_textView.attributedText isEqualToAttributedString:_pendingAttributedText]` check in -performPendingTextUpdate will fail and causes -[UITextView setText:] to be called.
4. -setText: clears the marked text range in the text view, which breaks multi-character autocomplete (e.g. QWERTY input methods for CJK languages).

The easiest fix for now is to just make sure RCTUITextView and RCTShadowText default to the same text color.

Reviewed By: nicklockwood

Differential Revision: D3368726

fbshipit-source-id: a92cb188c60bac80d963af6b1f2a09f27ae084f5
2016-06-06 12:58:37 -07:00
Nick Lockwood 44c9cf3a91 Refactored subview management
Reviewed By: javache

Differential Revision: D3392214

fbshipit-source-id: 6f16841df5cf866dda5ac27dd244e266ec85a86e
2016-06-06 10:28:33 -07:00
Nathan Azaria 724134746b Changed RCTTextView to check for failed focus
Reviewed By: nicklockwood

Differential Revision: D3378236

fbshipit-source-id: b4a33f7808ffe116b51631cde35f5cd0042caee9
2016-06-03 16:13:19 -07:00
Martín Bigio bbc6139baf Reverted commit D3348218
Summary:
The TextInput when configured with `multiline=true` has a minor issue due to which if the initial text doesn't fit in one line, the input won't span multiple lines. The root cause of the problem is that the `onChange` event is not fired for the initial render. This issue has been reported on open-source: 481f560f64

This is an attempt to fix this problem by moving the logic to fire the event to the method that updates the content size. This way we can guarantee that anytime the content size changes we'll trigger the JS event.

The downside of this approach is that it's possible that multiple events get fired for a single character change. As per the comment that was removed, this was already happening when adding a character that when rendered, would increase the content size. By moving the code to the new place, this can happen more often (twice per character tapped). Let me know if you think this is an issue.

I don't know this code much, so please be careful reviewing. I'm happy to add more test cases I may have missed to the test plan :).

Reviewed By: nicklockwood

Differential Revision: D3348218

fbshipit-source-id: 6b457624c9126e771c326eac61cd1cdd6496671d
2016-06-01 13:38:33 -07:00
Martín Bigio 572a85fa24 Fix multiline TextField initial render
Summary:
The TextInput when configured with `multiline=true` has a minor issue due to which if the initial text doesn't fit in one line, the input won't span multiple lines. The root cause of the problem is that the `onChange` event is not fired for the initial render. This issue has been reported on open-source: 481f560f64

This is an attempt to fix this problem by moving the logic to fire the event to the method that updates the content size. This way we can guarantee that anytime the content size changes we'll trigger the JS event.

The downside of this approach is that it's possible that multiple events get fired for a single character change. As per the comment that was removed, this was already happening when adding a character that when rendered, would increase the content size. By moving the code to the new place, this can happen more often (twice per character tapped). Let me know if you think this is an issue.

I don't know this code much, so please be careful reviewing. I'm happy to add more test cases I may have missed to the test plan :).

Reviewed By: nicklockwood

Differential Revision: D3348218

fbshipit-source-id: d3da3c0da1a0da9b9960625441191497e91d322e
2016-06-01 08:13:27 -07:00
Nick Lockwood d9737571c4 Updated AppState module to use new emitter system
Summary: AppState now subclasses NativeEventEmitter instead of using global RCTDeviceEventEmitter.

Reviewed By: javache

Differential Revision: D3310488

fbshipit-source-id: f0116599223f4411307385c0dab683659d8d63b6
2016-05-23 09:13:37 -07:00
Ben Nham 91dcc9ac8e Fix autocomplete in rich-text editing mode for CJK text input
Summary:This fixes autocomplete for CJK text input by making sure that the `<Text>` nodes that JS controls to produce attributed text matches the text view's attributed text as much as possible. This is done by giving the disconnected `<Text>` child the same style as the `<TextInput>` parent.

This works because `-[RKTextView performPendingTextUpdate]` avoids setting the attributedText property on textView if the JS attributedText and textView attributedText are equal. This is important because setting attributedText on a text view clears the autocomplete state (markedText property) on a text view, breaking autocomplete for multistage input styles like CJK with a phonetic keyboard.

Reviewed By: nicklockwood

Differential Revision: D3207513

fb-gh-sync-id: 02e582ea5f15191974f15a65ebc1820401715f8d
fbshipit-source-id: 02e582ea5f15191974f15a65ebc1820401715f8d
2016-04-21 12:10:25 -07:00
Nick 2a03182b1c CHORE - Remove Trailing Spaces
Summary:Remove Trailing Spaces.

Why:
Sometimes there are conflicts with trailing spaces
Saves space
Those whose tools automatically delete them will have their pr watered down with trailing space removal
Closes https://github.com/facebook/react-native/pull/6787

Differential Revision: D3144704

fb-gh-sync-id: d8a62f115a3f8a8a49d5b07f56c540a02af38cf8
fbshipit-source-id: d8a62f115a3f8a8a49d5b07f56c540a02af38cf8
2016-04-06 09:21:53 -07:00
Nick Lockwood 481f560f64 Added support for auto-resizing text fields
Summary:
public
This diff adds support for auto-resizing multiline text fields. This has been a long-requested feature, with several native solutions having been proposed (see https://github.com/facebook/react-native/pull/1229 and D2846915).

Rather than making this a feature of the native component, this diff simply exposes some extra information in the `onChange` event that makes it easy to implement this in pure JS code. I think this is preferable, since it's simpler, works cross-platform, and avoids any controversy about what the API should look like, or how the props should be named. It also makes it easier to implement custom min/max-height logic.

Reviewed By: sahrens

Differential Revision: D2849889

fb-gh-sync-id: d9ddf4ba4037d388dac0558aa467d958300aa691
2016-01-25 05:46:29 -08:00
Ben 09250aa184 multiline textinput view not wrapping in multiline on ios
Summary:
It's because the view doesn't update itself after setText.
Closes https://github.com/facebook/react-native/pull/5247

Reviewed By: svcscm

Differential Revision: D2819520

Pulled By: nicklockwood

fb-gh-sync-id: 06f5342d94f242fc63f862dac738da9b96842183
2016-01-11 03:33:30 -08:00
Andrew Crowell fe86771a22 Maintain cursor position when TextInput value is changed programmatically
Summary:
This is useful for applying input masks in the onChange handler that you then need to propagate down to the native component. In our case, we add commas as the user enters a price. Without this change, the cursor will end up in the wrong place when the text is transformed in our onChange handler.
Closes https://github.com/facebook/react-native/pull/4716

Reviewed By: svcscm

Differential Revision: D2766236

Pulled By: nicklockwood

fb-gh-sync-id: c4057d77d62507ec9e09eb0242888bf2858d822f
2015-12-17 10:23:26 -08:00
Nick Lockwood dde55c30ea This Fixes scroll to top and resigning first responder
Reviewed By: tadeuzagallo

Differential Revision: D2713488

fb-gh-sync-id: 99b2646f7bf8a3ee889bbb856c298beed6817321
2015-12-04 07:56:29 -08:00
Nick Lockwood 6d29f710e1 Fixed TextInput on iOS 8 and earlier
Summary:
public

The scrolling fix I added to RCTTextView doesn't work on iOS 8 because the underlying UITextField doesn't resize correctly, which breaks text input functionality. This diff fixes it.

Reviewed By: tadeuzagallo

Differential Revision: D2712618

fb-gh-sync-id: 1d0282df3a16f1cb6ddf9d005d640738bb1b5659
2015-12-02 10:37:26 -08:00
Nick Lockwood 37042573b8 Added blurOnSubmit support to multine TextInput (aka RCTTextView)
Summary:
public

Setting `blurOnSubmit=true` on a multiline `<TextInput>` now causes it to behave like a single-line input with respect to the return key:

With the default value of `false`, pressing return will enter a newline character into the field. If you set the value to `true`, pressing return will now blur the field and trigger the onSubmitEditing event. The newline character will *not* be added to the text.

(See associated github task for dicussion: https://github.com/facebook/react-native/pull/2149)

Reviewed By: javache

Differential Revision: D2710448

fb-gh-sync-id: c9706ae11f8b399932d3400ceb4c7558e455570d
2015-12-02 08:16:27 -08:00
Nick Lockwood 807e0d9310 Fixed Xcode warnings
Summary:
public

Fixed some Xcode warnings, and added some missing UIResponder methods to make the behavior of RCTTextView more self-consistent.

Reviewed By: javache

Differential Revision: D2712250

fb-gh-sync-id: d30038500194d7a5262d9e77d516c65d836a4420
2015-12-02 08:03:26 -08:00
Nick Lockwood 94f126ddbf Fixed TextInput.blur()
Reviewed By: helouree

Differential Revision: D2704065

fb-gh-sync-id: a4f5aa9c9b4fcb7980eb85289d16982840a980bd
2015-11-30 14:32:06 -08:00
Nick Lockwood 01a0facf33 Fixed onFocus/onBlur events for multiline TextInput
Summary: public

onFocus and onBlur were not firing for multiline TextInputs.

Reviewed By: tadeuzagallo

Differential Revision: D2699846

fb-gh-sync-id: 7e64309bc631a42a99f989f615fef927dc50217c
2015-11-27 07:47:28 -08:00
Nick Lockwood b5be05d82b Fix flaky scrolling for TextInput when using rich text
Summary: public

This diff fixes the jumpy scrolling for multiline `<TextInput>` when using nested `<Text>` components to implement rich text highlighting.

The fix is to disable scrolling on the underlying UITextView, and nest it inside another UIScrollView that we control.

Reviewed By: ericvicenti, tadeuzagallo

Differential Revision: D2674670

fb-gh-sync-id: bacee3ae485523cc26ca8102b714e081df230629
2015-11-24 15:38:27 -08:00
Nick Lockwood fa0b45c58b Replaced RCTSparseArray with NSDictionary
Reviewed By: jspahrsummers

Differential Revision: D2651920

fb-gh-sync-id: 953e2ea33abfc7a3a553da95b13e9ab2bccc5a1c
2015-11-14 10:28:28 -08:00
Nick Lockwood 5a34a097f2 Open sourced the onSelectionChange event
Summary: public

Open-sourced the onSelectionChange event for RCTTextView, and also added onSelectionChange support for RCTTextField.

Reviewed By: javache

Differential Revision: D2647541

fb-gh-sync-id: ab0ab37f5f087e708a199461ffc33231a47d2133
2015-11-14 09:44:30 -08:00
Nick Lockwood 7779e06a7f Added rich text input support
Summary: public

It is now possible to display and edit rich text inside a multiline `<textInput>` by nesting a `<Text>` node inside it.

Note that this doesn't yet provide everything needed to build a full rich text editor (as there is no facility to capture or control the selected text range, or insert/remove text) but it does make it possible to apply token-based styling to text as the user types.

See the 'Attributed text' example in the UIExplorer > TextInput demo for details.

Reviewed By: javache

Differential Revision: D2622493

fb-gh-sync-id: b6bc9a46005322c806934541966460edccb59e70
2015-11-06 07:26:27 -08:00
Nick Lockwood d799558db5 Fix Groups text input
Reviewed By: javache

Differential Revision: D2590712

fb-gh-sync-id: 453e20970460c703230547d8fd649383ba7d4c4a
2015-11-04 04:09:27 -08:00
Dave Sibiski 6c7c845145 Implements `onKeyPress`
Summary: - When a key is pressed, it's `key value` is passed as an argument to the callback handler.
 - For `Enter` and `Backspace` keys, I'm using their `key value` as defined [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key#Key_values). As per JonasJonny & brentvatne's [suggestion](https://github.com/facebook/react-native/issues/1882#issuecomment-123485883).

- Example
```javascript
 _handleKeyPress: function(e) {
      console.log(e.nativeEvent.key);
  },

  render: function() {
    return (
      <View style={styles.container}>
        <TextInput
            style={{width: 150, height: 25, borderWidth: 0.5}}
            onKeyPress={this._handleKeyPress}
        />
        <TextInput
            style={{width: 150, height: 100, borderWidth: 0.5}}
            onKeyPress={this._handleKeyPress}
            multiline={true}
        />
      </View>
    );
  }
```
- Implements [shouldChangeCharactersInRange](https://developer.apple.com/library/prerelease/ios/documentat
Closes https://github.com/facebook/react-native/pull/2082

Reviewed By: javache

Differential Revision: D2280460

Pulled By: nicklockwood

fb-gh-sync-id: 1f824f80649043dc2520c089e2531d428d799405
2015-11-02 09:15:31 -08:00
Kushal Dave 1d77645a53 Set scrollsToTop = NO for UITextViews
Summary: Complete the work from 853d5b2221 by also fixing the placeholder view.
Closes https://github.com/facebook/react-native/pull/3129

Reviewed By: @​svcscm

Differential Revision: D2499753

Pulled By: @vjeux
2015-10-02 10:18:31 -07:00