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.

keyboard not visible after dialog close

See original GitHub issue

Hi @mmazzarolo, I am using react-native-modal v4.1.1 and RN v0.52.

I looked at issue #53 but I still having issues.

I am using Android (in iOS it works fine without onModalHide): When my modal dialog is shown the keyboard is hidden - which is the behavior I want. When the dialog is closed the keyboard never shows up again, even though I am staying in the same screen.

my component that contain the modal dialog looks like this:

class ComponentA extends Component {
    constructor(props) {
        super(props);

        this.state = {
            isErrorDialogVisible: false,
        };
    }

    componentWillReceiveProps = (nextProps) => {
        is (nextProps.error) {
            this.setState({
                isErrorDialogVisible: true,
            });
        }
    }

    closeDialog = {
        this.setState({
            isErrorDialogVisible: false,
        })
    }

    render() {
        return(
            <View>
                <TextInput
                    .....
                />
                <Modal
                    isModalVisible={this.state.isErrorDialogVisible}
                    handleClick={this.closeDialog}
                />
            </View>
        )
    }
}

and my modal dialog component is something like:

export default class ModalDialog extends Component {

    onButtonClick = () => {
        this.props.handleClick();
    }

    render() {
        return(
            <View>
                <Modal
                    isVisible={this.props.isModalVisible}
                >
                    <View>
                        .....
                        <TouchableOpacity onPress={this.onButtonClick}>
                                ....
                        </TouchableOpacity>
                    </View>
                </Modal>
            </View>
        )
    }
}

After the dialog closes, I can see that closeDialog is called but the keyboard never pops up again? I tried to tried to regain focusthis.textInput.focus(); in componentWillUpdate method but with no luck.

using onModalHide method? Is there a way to call onButtonClick after onModalHide is called?

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
ancyrwebcommented, Mar 22, 2019

This isn’t directly related to react-native-modal, but the way Modal works in RN. It seems you cannot have the keyboard out for an input focused behind a modal. And while the modal is closing, the modal isn’t closed yet, it animates and then close.

You have to wrap your focus function into a setTimeout and wait for a few milliseconds before focusing on the input (0ms doesn’t work, 1ms seems to be ok).

The best I could do is to delay the moment we call onModalHide to the very last moment. We cannot inside the library wrap it into a setTimeout, this would just patch a few use cases and we would have to carry this fix around while it’s not supposed to be our problem.

This is addressed in https://github.com/react-native-community/react-native-modal/commit/a032d4d061a2a3d73092e7b42d295e64bf80efa4 and will be shipped in the next release.

1reaction
evanjmgcommented, Mar 22, 2019

There’s a better workaround. Run InteractionManager.runAfterInteractions(()=>{}) and inside it will be your focus event

On Mar 22, 2019, at 4:43 PM, Anthony Cyrille notifications@github.com wrote:

This isn’t directly related to react-native-modal, but the way Modal works in RN. It seems you cannot have the keyboard out for an input focused behind a modal. And while the modal is closing, the modal isn’t closed yet, it animates and then close.

You have to wrap your focus function into a setTimeout and wait for the animation to finish (check the value of the animationOutTiming) + a few milliseconds before focusing on the input.

The best I could do is to delay the moment we call onModalHide to the very last moment. We cannot inside the library wrap it into a setTimeout, this would just patch a few use cases and we would have to carry this fix around while it’s not supposed to be our problem.

This is addressed in a032d4d and will be shipped in the next release.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

Read more comments on GitHub >

github_iconTop Results From Across the Web

keyboard not visible after dialog close · Issue #114 - GitHub
After the dialog closes, I can see that closeDialog is called but the keyboard never pops up again? I tried to tried to...
Read more >
Soft keyboard appears after Dialog is closed - Stack Overflow
Every time I have focus on some edit field and Dialog shows up, it will pull up soft keyboard as soon as I...
Read more >
ARIA: dialog role - Accessibility - MDN Web Docs - Mozilla
After the dialog is dismissed, keyboard focus should be moved back to where it was before it moved into the dialog. Otherwise the...
Read more >
Modal dialogs - Access & Use
A keyboard user focuses the button "ADD CONTENT" which shows no visible focus, and activates it (see note) · The dialog opens ·...
Read more >
Accessible dialog tutorial - ally.js
Accessible dialog tutorial. This document explains what steps need to be taken in order to make a visually compelling, yet fully accessible dialog...
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