You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The search-bar has no way of dismissing an open keyboard. This makes the search-bar a quite unusable as the normal user pattern is that the user search for something and then press the item and gets navigated there. On Android (at least on >= 5.x), the open keyboard will continue to stay open, even on the new page. On iOS it will close.
the editable-text-base, and therefore the text-field, has a dismissSoftInput. Can this be implemented on the search-bar as well?
Related, it should probably have the focus() method as well.
Alright @TobiasHennig, thanks for getting me to look at the android documentation.
This seems to do the job.
var searchBar = page.getViewById("search-bar");
if (searchBar.ios) {
searchBar.ios.endEditing(true);
} else if (searchBar.android) {
searchBar.android.clearFocus();
}
Hi, I'd like to know how to implement dismissSoftInput for searchBar and how it works.
Any example running?
May I add this to .on(searchBarModule.SearchBar.clearEvent)?
I've tried the code bellow, but nothing happens on IOS device:
exports.pageLoaded=function(){varsearchBarModule=require('ui/search-bar');varsearchBar=page.getViewById('searchid');searchBar.on(searchBarModule.SearchBar.clearEvent,function(args){console.log('-- Cleanned Search for Contacts');searchBar.dismissSoftInput();});};
I like that cancel button thingy! For anyone using that: you can also make it appear animated, like this: searchBar.ios.setShowsCancelButtonAnimated(true, true);
I'm facing the same problem with search bar. The focus is unset but then on tab view change it gets focus and sometimes the keyboard pops up.Dont know whats the matter with this.
I had to wrap it in a timeout, but that's probably depending on when exactly the SearchBar is rendered.
I had to remove event.object.android.setFocusable(false); as that required me to tap the field twice before being able to enter anything in it. No side effects thus far.
Reacted by Nikolay Iliev, Douglas Franco, Jamie Sharpe, Manuel Lopera, abo ganas, nmongiya and Matthew
Activity
TobiasHennig commentedon Sep 30, 2015
I have the same problem and discover a bit of a workaround (iOS only):
Option 1: Dismiss input with a "Cancel" button

Option 2: Dismiss input programmatically
emiloberg commentedon Oct 1, 2015
Alright @TobiasHennig, thanks for getting me to look at the android documentation.
This seems to do the job.
emiloberg commentedon Oct 1, 2015
And for completness.
As the search-bar inherits from
Viewyou can callfocus()to set focus on the search-bar and that way make the keyboard visible.Footnote: Android seem to set focus on the search-bar when navigating to a page with such on it. iOS does however not.
leocaseiro commentedon May 24, 2016
Hi, I'd like to know how to implement dismissSoftInput for searchBar and how it works.
Any example running?
May I add this to
.on(searchBarModule.SearchBar.clearEvent)?I've tried the code bellow, but nothing happens on IOS device:
I also tried:
My last tried was similar the implementation on editable-text-base.ios.ts:
EddyVerbruggen commentedon Jun 5, 2016
I like that cancel button thingy! For anyone using that: you can also make it appear animated, like this:
searchBar.ios.setShowsCancelButtonAnimated(true, true);blaur commentedon Oct 26, 2016
Anyone who have a solution for android? Mine still seems to be behaving very strainge no matter the option I choose from in here.
dzfweb commentedon Feb 24, 2017
Still need for a solution in android.
dlucidone commentedon Feb 24, 2017
I'm facing the same problem with search bar. The focus is unset but then on tab view change it gets focus and sometimes the keyboard pops up.Dont know whats the matter with this.
grasshoppermouse commentedon Mar 16, 2017
Same problem on android. I've tried many different solutions that folks have posted here and on stackoverflow. Some crash my app, others don't work.
dlucidone commentedon Mar 16, 2017
Really want to fix this keyboard action
dzfweb commentedon Mar 16, 2017
I solved the keyboard opening, doing the following:
component.html
<SearchBar (loaded)="onSearchBarLoaded($event)"></SearchBar>component.ts
dlucidone commentedon Mar 16, 2017
@dzfweb I'm having problem in case of tab view and pull to refresh. each time i do any of the thing it gets poped up
dzfweb commentedon Mar 16, 2017
@dlucidone I have the same case of you, i have 3 tabs, each with a SearchBar.
While navigating on it, the keyboard still not open.
dlucidone commentedon Mar 16, 2017
@dzfweb I'll try and see if it works. Thanks
grasshoppermouse commentedon Mar 16, 2017
@dzfweb, your solution seems to work for me. Thanks!
EddyVerbruggen commentedon Mar 16, 2017
@dzfweb Thanks, that worked for me as well, although I needed 2 tweaks (on Android 4.4.4) I'd like to share:
event.object.android.setFocusable(false);as that required me to tap the field twice before being able to enter anything in it. No side effects thus far.Include test for issue #849 from nativescirpt-angular
Include test for issue #849 from nativescirpt-angular (#4421)
lock commentedon Aug 28, 2019
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.