Skip to content

Commit

Permalink
Add TextInput's prop caretHidden implementation for Android and add t…
Browse files Browse the repository at this point in the history
…he prop to docs

Summary:
This PR will:
- add missing documentation for `caretHidden` prop to the docs
- add `caretHidden` prop implementation for Android

I noticed this by accident when looking at `RCTTextFieldManager.m` and there is `RCT_EXPORT_VIEW_PROPERTY(caretHidden, BOOL)` which hides caret on iOS. Then I realised that the docs were missing for this prop and implementation on Android side :)

Render `TextInput` with prop `caretHidden`. After this caret is not visible anymore.
`<TextInput style={styles.input} caretHidden />`

If you omit the prop then caret is visible again
`<TextInput style={styles.input} />`
Closes #11863

Differential Revision: D4448402

fbshipit-source-id: 456e1df3e2cbb8af32540d2c7a8f4e7da219f5c3
  • Loading branch information
Henrik Raitasola authored and facebook-github-bot committed Feb 24, 2017
1 parent fab0992 commit bb1f851
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Libraries/Components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,10 @@ const TextInput = React.createClass({
PropTypes.oneOf(DataDetectorTypes),
PropTypes.arrayOf(PropTypes.oneOf(DataDetectorTypes)),
]),
/**
* If `true`, caret is hidden. The default value is `false`.
*/
caretHidden: PropTypes.bool,
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,11 @@ private void setCursorColor(ReactEditText view, @Nullable Integer color) {
} catch (IllegalAccessException ex) {}
}

@ReactProp(name = "caretHidden", defaultBoolean = false)
public void setCaretHidden(ReactEditText view, boolean caretHidden) {
view.setCursorVisible(!caretHidden);
}

@ReactProp(name = "selectTextOnFocus", defaultBoolean = false)
public void setSelectTextOnFocus(ReactEditText view, boolean selectTextOnFocus) {
view.setSelectAllOnFocus(selectTextOnFocus);
Expand Down

2 comments on commit bb1f851

@henrikra
Copy link

Choose a reason for hiding this comment

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

Can you guys add my name to release notes since I implemented this :D?

@satya164
Copy link
Contributor

Choose a reason for hiding this comment

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

@henrikra sorry, just did that. it's a bit manual work since the commit doesn't have you as the user, probably because different email address.

Please sign in to comment.