question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] Helper to dismiss keyboard

See original GitHub issue

Currently, as far as I can tell, you have to have a reference to a TextField or similar in order to call the dismissSoftInput method. This feels hacky when, for instance, you want to dismiss the keyboard when a certain action is taken by a user in order to show more of the screen.

This is the only way that I know of to dismiss the keyboard, whether or not the field is focused:

const field = <TextField>this.page.getViewById('first-name');
field.dismissSoftInput();

I don’t think that this code clearly expresses the intent of the developer, and could be more concise with something such as:

this.page.dismissSoftInput();

If something similar to this approach is already possible, please let me know.

<bountysource-plugin>

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:11
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

10reactions
darylteocommented, Mar 24, 2020

@bearoutthere thank you so much for that code for ios!

Just want to note that there is a typo, which took me awhile to figure out. The single quote is in the wrong place. Don’t copy and paste without reading, folks!

import * as nsutils from 'tns-core-modules/utils/utils';
import { ios } from 'tns-core-modules/application';

export const hideKeyboard = () => {
    if (ios) {
        ios.nativeApp.sendActionToFromForEvent('resignFirstResponder', null, null, null);
    } else {
        nsutils.ad.dismissSoftInput();
    }
};
10reactions
bhavincbcommented, Mar 9, 2018

if nativescript can provide extra event binding support like ‘focus’ and ‘blur’ than it will be great to have it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Best way to dismiss Keyboard in a View Controller iOS (Swift)
First way: Implement UITextFieldDelegate's textFieldShouldReturn method and dismiss current keyboard. this solution seems good enough but not ...
Read more >
Close iOS Keyboard by touching anywhere using Swift
An answer to your question on how to dismiss the keyboard in Xcode 6.1 using Swift below: import UIKit class ItemViewController: UIViewController, ...
Read more >
How to dismiss iOS keyboard programatically (Swift 5)
This is the quickest way to implement keyboard dismissal. Just set a Tap gesture on the main View and hook that gesture with...
Read more >
Dismiss Keyboard SwitUI | Apple Developer Forums
Is there a way to dismiss a decimal Keyboard by tapping (anywhere) on the screen (without putting .onTapGesture {hideKeyboard()} on the NavigationView)
Read more >
Swift iOS Dismiss Keyboard - YouTube
In this Swift iOS tutorial, we will go over 3 ways to dismiss the keyboard on an iOS device.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found