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

Use defineModel instead of custom useVModel composable #994

Open
mlmoravek opened this issue Jul 3, 2024 · 0 comments
Open

Use defineModel instead of custom useVModel composable #994

mlmoravek opened this issue Jul 3, 2024 · 0 comments
Labels
bug Something isn't working refactoring This involves some refactoring of existing code.

Comments

@mlmoravek
Copy link
Member

mlmoravek commented Jul 3, 2024

Overview of the problem

Oruga version: [0.8.]
Vuejs version: [3.4.]

With several releases from 0.8.3 untill 0.8.10, we changed our custom useVModel composable to the Vue native defineModel implementation for bi-directional properties.

However, there are some issues with defineModel that prevent us from implementing further type support and enhancements.
Our component documentation process relies entirely on the vue-docgen-api. On #985 we have already enhanced it with a vue-component-meta integration, which allows us to use more modern Vue features.

But vue-component-meta cannot extract definModel js-doc comments, so we also have to define the property in defineProps with the js-doc comment ahead as well as in defineEmits, but also have defineModel for the implementation purpose.

Actual behavior

Now the problem we have is that Vue has some problems merging the defineProps with the defineModel type definition of a property that is typed by a component generic type.

image

This seems to be an known vue core issue and might be fixed with Vue 3.5 (vuejs/core#10801), but is not quite ready yet (vuejs/core#9652, vuejs/core#9277).

Therefore, I reverted some two-way-binded props with a custom useVModel composable in #998, which implements the bi-directional behaviour at runtime and is fully dependent on the defineProps and defineEmits definitions, instead of the compile-time definModel macro.

Expected behavior

The type of a property defined in both defineModel and defineProps will merge properly when using generic types.

Any bi-directional property should work with generic component types.

@mlmoravek mlmoravek added bug Something isn't working workaround refactoring This involves some refactoring of existing code. labels Jul 3, 2024
@mlmoravek mlmoravek changed the title revert defineModel with custom composable revert defineModel back to custom composable Jul 3, 2024
@mlmoravek mlmoravek changed the title revert defineModel back to custom composable Use defineModel instead of custom useVModel composable Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working refactoring This involves some refactoring of existing code.
Projects
None yet
Development

No branches or pull requests

1 participant