Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Blur & Focus] Support relinquishing focus from multiple views via co… #2203

Closed
wants to merge 2 commits into from

Conversation

josebalius
Copy link

…ntainer - #113

This adds the ability to call this.refs.parentView.blur() and blur any active text fields inside the view. It will first try to blur the field (already supported) and if the field is not found as an "active" text field, it will transverse the view and resignFirstResponder for each of them.

I am currently using it in my app and works well.

@facebook-github-bot facebook-github-bot added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Aug 2, 2015
[view resignFirstResponder];
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You should be able to do something like [subview endEditing:YES] instead of doing the complete traversal. Also can remove the uiManager parameter since self == uiManager.

UIView *view = uiManager.viewRegistry[reactTag];
if (view) {
  [view endEditing:YES];
} else {
  // Recurse through the shadow hierarchy when the shadow view has no backing UIView
  for (RCTShadowView *subview in [shadowView reactSubviews]) {
    [self endEditingForShadowView:subview.reactTag viewRegistry:viewRegistry];
  }
}

Copy link
Author

Choose a reason for hiding this comment

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

@ide Makes perfect sense, i'll make the changes, test and commit.

- Using endEditing vs resignFirstResponder as it is more efficient.
@josebalius
Copy link
Author

@ide Made the changes you requested and tested them in my app and everything seems to work great, let me know if you think anything else is needed.

@brentvatne
Copy link
Collaborator

I like this 😄 👍

@josebalius
Copy link
Author

@brentvatne not sure what went wrong with the build?

@brentvatne
Copy link
Collaborator

@josebalius - if #113 works (assuming we can resolve the issue you mentioned in #113 (comment)) is this still needed?

@facebook-github-bot
Copy link
Contributor

@josebalius updated the pull request.

@ghost
Copy link

ghost commented Mar 3, 2016

@spicyj would you mind taking a look at this pull request? It's been a while since the last commit was reviewed.

@mkonicek
Copy link
Contributor

@josebalius Can you please indicate whether this PR is still needed? See the comment by Brent Vatne:

if #113 works (assuming we can resolve the issue you mentioned in #113 (comment)) is this still needed?

@ghost
Copy link

ghost commented May 20, 2016

It's been a while since the last commit was reviewed and the labels show this pull request needs review. Based on the blame information for the files in this pull request we identified @nicklockwood as a potential reviewer. Could you take a look please or cc someone with more context?

@josebalius
Copy link
Author

I think this can probably be closed guys.

@mkonicek
Copy link
Contributor

Thanks for looking @josebalius. I assume this was resolved in #113?

We are exposing TextInputState in #3308 which will allow you to do this too. I'm not sure it's worth exposing this one line function as it will increase API surface area ...

@mkonicek mkonicek closed this May 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants