GithubHelp home page GithubHelp logo

Comments (6)

rich1888 avatar rich1888 commented on July 22, 2024

I'd also like to know how to stop this if possible.

Im using it with livewire and allowing multiple selections.

When you select an option after searching it is breaking the rule that selections should be an array as on the first change event the value is a string (the search term), and immediately after that the change event is triggered again with the selected values as an array.

from virtual-select.

vivekmakwanadikus avatar vivekmakwanadikus commented on July 22, 2024

I have made a hotfix for it. I'm using this with jQuery event listeners.

$(document).on("change", ".foo", function (e) {
    if (virtualSelectFix($(this), e)) {
        return;
    }
})
function virtualSelectFix(that, event) {
    if (that.val() !== event.target.value) {
        return true;
    }
    return false;
}

from virtual-select.

gnbm avatar gnbm commented on July 22, 2024

@sa-si-dev could you help clarifying this?

from virtual-select.

rich1888 avatar rich1888 commented on July 22, 2024

This is still causing some issues.

When you search and hit enter, the value passed is the string you searched, and not the option you selected.

@sa-si-dev Could you help please 🙏

from virtual-select.

ShaunWilders avatar ShaunWilders commented on July 22, 2024

I can confirm the search value is being passed back as the value before the selected value/s. I have this setup as a Livewire component and have managed to ignore the search value for now, but as I'm not using onServerSearch there's no need for the search value to be passed back at all.

from virtual-select.

ShaunWilders avatar ShaunWilders commented on July 22, 2024

@rich1888, I am also using this as a livewire component but I have it setup as a reusable component using livewire/livewire#4725 as my starting point.

Technically, the search input is changing, but I have tweaked the x-on:change attribute to only set the model value (and as a result, trigger a livewire update) if the className is "vscomp-ele pop-comp-ele pop-comp-active" or "vscomp-ele pop-comp-ele":

original:
'x-on:change="select = event.target.value"'

tweak:
'x-on:change="if(event.target.className=='vscomp-ele pop-comp-ele' || event.target.className=='vscomp-ele pop-comp-ele pop-comp-active'){select = event.target.value;}"'

I added console.log(event); into the attribute while testing to see all available attributes:
'x-on:change="console.log(event);select = event.target.value"'

from virtual-select.

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.