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

The SelectedOption and SelectedOptions returns empty results and they reactive using the useSelect composable #100

Closed
boussadjra opened this issue Jan 7, 2025 · 5 comments · Fixed by #101
Assignees
Labels
🐞 bug Something isn't working ❗️ p1-high Important tasks or features with significant impact on users or the project

Comments

@boussadjra
Copy link

Describe the bug
I want to get the SelectedOption or SelectedOptions inside the SelectField component based on the useSelect composable in order to be able to return the option label and show it inside the input box, However this is not reactive and it returns empty result at the first rendering

To Reproduce
Please check this playground example then inside the SelectField component I logged these return values (selectedOption and selectedOptions) where you can see the described issue

Expected behavior

I expect to get the selectedOption object or selectedOptions array whenever I select an option

  • @formwerk/core : 0.5.0
@boussadjra boussadjra added the ⏳ triage Evaluate the issue and assign the appropriate priority label label Jan 7, 2025
@logaretm logaretm added 🐞 bug Something isn't working 🛠️ p2-medium Issues that should be addressed but are less urgent ❗️ p1-high Important tasks or features with significant impact on users or the project and removed ⏳ triage Evaluate the issue and assign the appropriate priority label 🛠️ p2-medium Issues that should be addressed but are less urgent labels Jan 7, 2025
@logaretm logaretm self-assigned this Jan 7, 2025
@logaretm logaretm linked a pull request Jan 7, 2025 that will close this issue
logaretm added a commit that referenced this issue Jan 7, 2025
* fix: use deep ref for selectedOptions reactivity closes #100

* chore: added changeset

* test: added tests to selection state
@logaretm
Copy link
Member

logaretm commented Jan 7, 2025

Fixed with v0.5.1

@boussadjra
Copy link
Author

Thanks, it works fine but when you close the popover the value will be reset to undefined/[]. I want to render its label inside the input box

@logaretm
Copy link
Member

logaretm commented Jan 7, 2025

I don't think that happens, or I don't observe this behavior in the example you provided. Can you provide another one?

@boussadjra
Copy link
Author

It's weird, it works on the online playground but in my local project it doesn't. I try to investigate it more

@logaretm
Copy link
Member

logaretm commented Jan 7, 2025

If in your local project you are using v-if to hide the options then it may cause this, this applies if you are hiding the entire dropdown or not. Basically we want the options to be in VDOM at all times.

Alternatively, try wrapping them with keep-alive, maybe this is the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working ❗️ p1-high Important tasks or features with significant impact on users or the project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants