Skip to content
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

Classes prop doesn't respond to changes when computed #126

Closed
stevebauman opened this issue Sep 13, 2021 · 5 comments
Closed

Classes prop doesn't respond to changes when computed #126

stevebauman opened this issue Sep 13, 2021 · 5 comments

Comments

@stevebauman
Copy link

stevebauman commented Sep 13, 2021

Version

  • Vue version: 3

Description

First off, thanks for the work on this! I really like this select component ❤️

When providing the classes prop as a computed property, multiselect doesn't apply the changes (i.e. is not reactive to the change).

I'm struggling attempting to apply "invalid" styling to the element, since the component doesn't re-compute class name changes.

Demo

https://jsfiddle.net/phuqkv0b/

When changing invalid to true and re-running the fiddle, the text and container border is appropriately changed to red. However, changing it dynamically via a button (for example) does not update the classes and reflect the necessary class changes.

@timoransky
Copy link

Hey, just found out about this problem as well. Any chanes we can get this fixed? Otherwise it's pretty impossible to style the Multiselect for invalid/error state :/

@stevebauman
Copy link
Author

Hey @timoransky, I'm going to try and work on a PR, though I'm not convinced it'll get merged.

Not sure if this will help you, but to work around this at the moment I've place a wrapper around the <Multiselect> element:

<!-- Dropdown.vue -->
<template>
    <div
        :class="{
            'sm:text-xs': size === 'sm',
            'sm:text-sm': size === null,
            'sm:text-lg': size === 'lg',
            'border-gray-300': !isInvalid,
            'border-red-300 text-red-900': isInvalid,
        }"
        class="relative border rounded-md shadow-sm"
    >
        <Multiselect />
    </div>
</template>

<script>
export default {
    props: ['size', 'isInvalid'],

    // ...
}
</script>

This can get tricky since you'll have to make sure the border radius in your <Multiselect/> classes matches the wrappers border radius (not ideal).

@timoransky
Copy link

Hey, thanks a lot! I did it in very similar way.

adamberecz added a commit that referenced this issue Dec 16, 2021
@adamberecz
Copy link
Collaborator

Thanks for reporting @stevebauman - classes were indeed not reactive. This got fixed in 2.3.0.

@stevebauman
Copy link
Author

Thanks @adamberecz! Really appreciate it 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants