GithubHelp home page GithubHelp logo

UiAutocomplete about keen-ui HOT 10 CLOSED

josephuspaye avatar josephuspaye commented on May 19, 2024
UiAutocomplete

from keen-ui.

Comments (10)

athikrishnan avatar athikrishnan commented on May 19, 2024 1

@JosephusPaye Not to rush but i could really use a select component in the coming week. going to use keen-ui on a product. :)

from keen-ui.

JosephusPaye avatar JosephusPaye commented on May 19, 2024

The behavior you are describing (where the text and value are synced separately) was removed when I rewrote the autocomplete in v0.8.6.

Now it only only auto-completes the user's input, therefore there is only one prop to watch, the value.

What you want is more like a select component, which I plan on adding soon.

from keen-ui.

EmilMoe avatar EmilMoe commented on May 19, 2024

I want a select too yes. But I use the auto complete to search for collections in the database like users. I want the users name to be displayed, but I want to submit the users ID.

from keen-ui.

JosephusPaye avatar JosephusPaye commented on May 19, 2024

In that case you could use the text (value) to find the ID if you have it in a suggestions array. This is how it was done in v0.8.5:

function findValue(text) {
    // Just return the text if suggestions is an array of strings
    if (this.suggestions[0] && typeof this.suggestions[0] === 'string') {
        return text;
    }
    text = text.toLowerCase();
    for (let i = 0; i < this.suggestions.length; i++) {
        if (this.suggestions[i].text.toLowerCase() === text) {
            return this.suggestions[i].value;
        }
    }
    return null;
}

You can then run this function on submit to find the user ID. The new select component will have this functionality by default.

from keen-ui.

EmilMoe avatar EmilMoe commented on May 19, 2024

I'm not sure if we differentiate a select and an auto complete the same way?

For me a select has a preset range of values and don't have a search option
The auto complete has a dynamic set of values and they are found by searching

from keen-ui.

JosephusPaye avatar JosephusPaye commented on May 19, 2024

A select can also be dynamic and have search. Like, for example, Select2.

But a select doesn't allow the user to select a value that's not in the options, while an autocomplete allows for entering any text, even if it's not in the suggestions.

from keen-ui.

EmilMoe avatar EmilMoe commented on May 19, 2024

That's true.

Do you have an idea when you have it finished?

And thanks for the code, it fails if 2 users has the same name, but it will work for now.

from keen-ui.

JosephusPaye avatar JosephusPaye commented on May 19, 2024

Not sure, but I've already started work on it and it might be done by Friday.

from keen-ui.

EmilMoe avatar EmilMoe commented on May 19, 2024

Perfect :-)

from keen-ui.

JosephusPaye avatar JosephusPaye commented on May 19, 2024

A Select and Slider component just landed in v0.8.8.

from keen-ui.

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.