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

SelectMenu label by options #1151

Closed
ElYaiko opened this issue Dec 22, 2023 · 8 comments
Closed

SelectMenu label by options #1151

ElYaiko opened this issue Dec 22, 2023 · 8 comments
Labels
enhancement New feature or request

Comments

@ElYaiko
Copy link

ElYaiko commented Dec 22, 2023

Description

When using optionAttribute in USelectMenu is selecting the label from the actual modelValue instead of the options.
It would be more useful get the label from the actual options so an additional slot label has not to be created just to show the needed attribute (ex: name) instead of the the value (ex: id).

Thanks!.

Additional context

No response

@ElYaiko ElYaiko added the enhancement New feature or request label Dec 22, 2023
@Hossein-Mirazimi
Copy link

I'm not sure if the proposed solution is the best approach. The modelValue is already being selected from the options, and updating the modelValue also updates the label text from the optionAttribute key. Therefore, I'm not sure if the proposed solution would add much value.

@ElYaiko
Copy link
Author

ElYaiko commented Jan 5, 2024

I'm not sure if the proposed solution is the best approach. The modelValue is already being selected from the options, and updating the modelValue also updates the label text from the optionAttribute key. Therefore, I'm not sure if the proposed solution would add much value.

I think this component should be improved because you also have the by prop to compare the VModel and valueAttribute to define the VModel, so it's a bit confusing.

It would be better to work with only one prop when working with objects, no valueAttribute will compare and define with full object and when set will compare and define with the defined property, and optionAttribute to only specify the label.

@Hossein-Mirazimi
Copy link

I'm not sure if the proposed solution is the best approach. The modelValue is already being selected from the options, and updating the modelValue also updates the label text from the optionAttribute key. Therefore, I'm not sure if the proposed solution would add much value.

I think this component should be improved because you also have the by prop to compare the VModel and valueAttribute to define the VModel, so it's a bit confusing.

It would be better to work with only one prop when working with objects, no valueAttribute will compare and define with full object and when set will compare and define with the defined property, and optionAttribute to only specify the label.

I think you right

I fix this as soon as possible

I plan to remove by props and only use valueAttribute to clarify how to use selectmenu

@Hossein-Mirazimi
Copy link

@benjamincanac

What do you think about this enhancement suggestion?

Copy link
Member

@Hossein-Mirazimi The by prop is used underneath by Headless UI Combobox component: https://headlessui.com/vue/combobox#binding-objects-as-values, you cannot remove it.

@ElYaiko
Copy link
Author

ElYaiko commented Jan 9, 2024

@Hossein-Mirazimi The by prop is used underneath by Headless UI Combobox component: https://headlessui.com/vue/combobox#binding-objects-as-values, you cannot remove it.

@benjamincanac
Yes, but you could do this improvement internally so this component would be easier to use.

Copy link
Member

I'm not sure to understand the issue here. Is this about the optionAttribute or the valueAttribute? Because the displayed value already comes from the modelValue: https://github.com/nuxt/ui/blob/dev/src/runtime/components/forms/SelectMenu.vue#L40

@ElYaiko
Copy link
Author

ElYaiko commented Jan 10, 2024

I'm not sure to understand the issue here. Is this about the optionAttribute or the valueAttribute? Because the displayed value already comes from the modelValue: https://github.com/nuxt/ui/blob/dev/src/runtime/components/forms/SelectMenu.vue#L40

Both, optionAttribute because is showing the label from the modelValue and valueAttribute because requires an additional prop by to work properly.

I think this component should be improved because you also have the by prop to compare the VModel and valueAttribute to define the VModel, so it's a bit confusing.

It would be better to work with only one prop when working with objects, no valueAttribute will compare and define with full object and when set will compare and define with the defined property, and optionAttribute to only specify the label.

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

No branches or pull requests

3 participants