jdehlin/Xamarin-Sidebar — pull request #10 by DennisWelu (2014-10-19 03:25:32+00:00)
Title: Resigning first responder for Open and Close instead of just Toggle

In my use case I have a SearchBar in the menu. Works great, except the keyboard is not dismissing when the menu closes. I can work around that with some ways that the menu can be closed...but simply tapping on the content area is all handled inside the SidebarController. Looking into the code I noticed the ToggleMenu method had logic to resign first responder for the content area. This doesn't help for text fields in the menu, and actually also doesnt help if you call Close direct, which is what was happening.

I ended up doing a couple things. One thing is just using EndEditing(true) instead of the recursive ResignFirstResponders. Perhaps there's a functional difference but from what I can tell it accomplishes the same thing, and searching around it looks like performance of EndEditing v. ResignFirstResponder is negligible.

The other thing was to move the EndEditing calls into OpenMenu and CloseMenu methods so that whether you use ToggleMenu or Open/Close the same logic applies. The logic actually ends editing on the menu when the menu is closing, and ends editing on the content if the menu is opening.

One other change came along for the ride in this PR, just removing an unused symbol warning.

Thanks for sharing the component - it's simple and easy to use!