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

v-model on a custom element (select v-model) #1800

Open
Benoit-Vasseur opened this issue Aug 6, 2020 · 4 comments
Open

v-model on a custom element (select v-model) #1800

Benoit-Vasseur opened this issue Aug 6, 2020 · 4 comments
Labels

Comments

@Benoit-Vasseur
Copy link

Version

3.0.0-rc.5

Reproduction link

https://github.com/vuejs/vue-next/blob/master/packages/compiler-dom/src/transforms/vModel.ts#L93

Steps to reproduce

  • try to us a web component with the "select api"

What is expected?

Be able to specify type=select for a web component ?

What is actually happening?

V_MODEL_SELECT is hard coded to the select tag so we cannot we this directive with a custom element.


To complete this one : #1699

It is a custom component so yes we can provide api compatible with other(s) directive(s) (combo text lazy for example) but I think that it is a valuable use case.
What do you think ?

Otherwise it is working great with custom elements using others directives, thanks !

@posva
Copy link
Member

posva commented Aug 6, 2020

Do you mean adding a extra check at https://github.com/vuejs/vue-next/blob/master/packages/compiler-dom/src/transforms/vModel.ts#L64 to allow type="select" on a custom component?

@yyx990803
Copy link
Member

yyx990803 commented Aug 6, 2020

This one is tricky because <select> relies on specific behavior with its interaction with <option> elements inside of it. So it won't work unless you implement your custom <select> and <option> with the exact same behavior as the native ones (i.e. reflecting options into DOM properties like .options, .selectedInex, .value, and vice-versa).

@ais-one
Copy link

ais-one commented Aug 12, 2020

I used

@material/mwc-select
@vaadin/vaadin-select

v-model does not do anything but :value and @change is good enough...

@pikax
Copy link
Member

pikax commented Oct 20, 2023

Looking at the both

@material/mwc-select
@vaadin/vaadin-select

Seems to be a pretty difficult to support them, since each implementation varies quite a bit.

The only way I would suppose to fix this is with aria-* we could infer the option based on aria-keys and whatnot, but I believe it would be pretty complicated to traverse the key for the v-model.
IMO we need an API to allow expand the v-model or recommend to create a component on top of select web component.

@pikax pikax added the ✨ feature request New feature or request label Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants