-
Notifications
You must be signed in to change notification settings - Fork 537
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
Reactive props with programmatic modals #2274
Comments
If your const localModalValue = ref(false);
const isLoading = ref(false);
useModal().open(MyModal, {
modelValue: localModalValue.value,
isLoading: isLoading.value,
'onUpdate:modelValue': value => localModalValue.value = value,
'onUpdate:isLoading': value => isLoading.value = value,
}); This example assumes the events that update those props are |
@noook This part is fine, the issue is that if i update |
Yes, this is a caveat of using programmatic modals. Values are only passed at instantiation and are not tracked by the reactive system at this point. Your usage of the modal by passing refs should make the modal reactive to the ref changes. Typescript might complain but it could actually work. Isn't it already reactive ? |
You can use patch const localModalValue = ref(false);
const isLoading = ref(false);
const modal = useModal();
modal.open(MyModal, {
modelValue: localModalValue,
isLoading: isLoading,
});
watch(isLoading, () => modal.patch<typeof MyModal>({ isLoading: isLoading })); |
Description
Heya. Is there a way to open a modal, while passing props and keep their reactivity?
The text was updated successfully, but these errors were encountered: