Giter Site home page Giter Site logo

Comments (4)

baptistedonaux avatar baptistedonaux commented on June 28, 2024

@dalf Are you sure that the form is really sent because if I see the last released source code, I can see a preventDefault call.

I can't reproduce the same fail. Do you have others informations to reproduce the issue ?

from autocomplete.js.

ezkimo avatar ezkimo commented on June 28, 2024

I have the same issue with HTML5 forms with validation constraints. Reproducable on current versions of Microsoft Edge, Mozilla Firefox and Google Chrome browsers. Safari was not tested.

AutoComplete( { ... }, 'input[name="zipcode"]' );

No special options where set. Just a url for the request and a limit. When iterating through the results with the up and down keys and then pressing enter, to select an item, the form triggers the invalid event. If all elements are valid the form submits. The _Select method is not executed.

After a deep dive into the code I found out, that the default keyboard mapping KeyUpAndDown_down ist triggered before Enter. So Enter never gets fired, because the key code 13 is not set in the conditions of KeyUpAndDown_down.

A small hotfix for this issue to get it working correctly.

var mapping = Object.assign(AutoComplete.defaults.KeyboardMappings, {
    'KeyUpAndDown_down' : {
        Conditions : [
            {
                Is : 38,
                Not : false
            },
            {
                Is : 40,
                Not : false
            },
            {
                Is : 13,
                Not : false
            }
        ],
        Callback : function(event) {
            event.preventDefault();
        },
        Operator : 1,
        Event : 0
    }
});
AutoComplete(
    {
        KeyboardMappings : mapping
    },
    'input[name="zipcode"]'
);

Now you can iterate through the results with the up and down keys and select an item with enter.

from autocomplete.js.

dalf avatar dalf commented on June 28, 2024

I've just made a quick example : https://github.com/dalf/autocomple-test

from autocomplete.js.

baptistedonaux avatar baptistedonaux commented on June 28, 2024

This issue has been resolve into 2.6.3. Sorry for the response time !

from autocomplete.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.