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

Filterable component misses next key after enter #7830

Closed
sergioberna opened this Issue Nov 7, 2014 · 1 comment

Comments

Projects
None yet
3 participants
@sergioberna

sergioberna commented Nov 7, 2014

On jquery mobile version 1.4.5 any filterable component stops responding to the next key press after pressing the intro key.

To reproduce you can go to the examples for filterable on http://demos.jquerymobile.com/1.4.5/filterable/ input some characters on the first filterable component, press the enter key and then type again. The first character you type will always be ignored and only the second you type will be accepted.

@slavap

This comment has been minimized.

Show comment
Hide comment
@slavap

slavap Nov 11, 2014

It's a bug in $.widget( "mobile.filterable" ).
The following code is incorrect:

        // Prevent form submission
    _onKeyDown: function( event ) {
        if ( event.keyCode === $.ui.keyCode.ENTER ) {
            event.preventDefault();
            this._preventKeyPress = true;
        }
    },

    _onKeyPress: function( event ) {
        if ( this._preventKeyPress ) {
            event.preventDefault(); // << PROBLEM is here!
            this._preventKeyPress = false;
        }
    }, 

Luckily there is a simple workaround, just add the following script to your project (after jqm):

$.widget( "mobile.filterable", $.mobile.filterable, {
    _onKeyPress: function( event ) {
        if ( this._preventKeyPress ) {
            if ( event.keyCode === $.ui.keyCode.ENTER ) event.preventDefault();
            this._preventKeyPress = false;
        } else {
            this._super( event );
        }
    }
});

slavap commented Nov 11, 2014

It's a bug in $.widget( "mobile.filterable" ).
The following code is incorrect:

        // Prevent form submission
    _onKeyDown: function( event ) {
        if ( event.keyCode === $.ui.keyCode.ENTER ) {
            event.preventDefault();
            this._preventKeyPress = true;
        }
    },

    _onKeyPress: function( event ) {
        if ( this._preventKeyPress ) {
            event.preventDefault(); // << PROBLEM is here!
            this._preventKeyPress = false;
        }
    }, 

Luckily there is a simple workaround, just add the following script to your project (after jqm):

$.widget( "mobile.filterable", $.mobile.filterable, {
    _onKeyPress: function( event ) {
        if ( this._preventKeyPress ) {
            if ( event.keyCode === $.ui.keyCode.ENTER ) event.preventDefault();
            this._preventKeyPress = false;
        } else {
            this._super( event );
        }
    }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment