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

feat: Select with options that can be refreshed #687

Open
3 tasks done
AlexisLeblancDFO opened this issue Nov 13, 2024 · 4 comments
Open
3 tasks done

feat: Select with options that can be refreshed #687

AlexisLeblancDFO opened this issue Nov 13, 2024 · 4 comments

Comments

@AlexisLeblancDFO
Copy link

AlexisLeblancDFO commented Nov 13, 2024

Prerequisites | Prérequis

Describe the feature request. | Décrivez la fonctionnalité demandée

Currently, select options are difficult to work with when they are populated by values received from API calls.
For example:

image

Since "options" are empty when page is loaded, the select component will be empty.
The "for" loop is removed once the component is generated once, so it doesn't get updated when the options are received from the server.

It makes it difficult to refresh the value dynamically.

Describe the use case. | Décrivez les cas d’utilisation

Useful when the options are being loaded or changed.

Describe the preferred solution. | Décrivez la solution souhaitée

No response

Describe all alternatives. | Décrivez toutes les solutions possibles

No response

Provide related code or examples. | Fournissez du code ou des exemples pertinents

No response

Add other relevant resources. | Ajoutez toute autre ressource utile

No response

@theonlyguills
Copy link

theonlyguills commented Nov 18, 2024

Hi! See #684 for the same problem and a workaround

@ethanWallace
Copy link
Collaborator

Hey @AlexisLeblancDFO In our v0.26.3 update we did some work to address this within the gcds-select. Would you be able to test and see if you are still having this issue on that version of gcds-components?

@theonlyguills
Copy link

Hi,

I was able to repro the bug on 0.26.3 using the stackblitz linked from #684

Thanks!

@theonlyguills
Copy link

Vue uses the key property internally to manage what it re-renders. By changing the key property, it forces a re-render of the select with the new options. Can be seen in the same stackblitz linked above.

Basically:
image

and updating the key value to force new options

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