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

useI18n does not work in a setup script within the context of a programmatically opened Modal #153

Closed
kikuomax opened this issue Dec 3, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@kikuomax
Copy link
Collaborator

kikuomax commented Dec 3, 2023

Overview of the problem

Buefy version: [0.1.3-8518d47780e734635d6e6cd8fa2ce32f3685e1d0]
Vuejs version: [3.3.9]
OS/Browser: Safari

Description

useI18n did not work in a setup script within the context of a programmatically opened Modal. I faced the following error:

Unhandled Promise Rejection: SyntaxError: Need to install with `app.use` function

I found this while investigating this discussion.

Steps to reproduce

<script setup>
import { useI18n } from 'vue-i18n'

const { t } = useI18n()
</script>

Expected behavior

Get no error.

Actual behavior

Got an error.

@kikuomax kikuomax self-assigned this Dec 3, 2023
@kikuomax kikuomax added the bug Something isn't working label Dec 3, 2023
@kikuomax
Copy link
Collaborator Author

kikuomax commented Dec 3, 2023

I came up with a quick patch, though, it is very specific to vue-i18n.

Why this happened

A programmatically opened Modal is hosted on a Vue app different from the main Vue app. This caused a problem that no plugins installed into the main Vue app were available on the Vue app hosting Modal. This problem was fixed by #102 by copying the app context from the main Vue app to the Vue app hosting Modal. However, vue-i18n injects another private field (__VUE_I18N_SYMBOL__) in Vue apps, which is not addressed by #102. useI18n throws an error if a Vue app does not have the field.

Quick patch

Copy __VUE_I18N_SYMBOL__ from the main Vue app to the Vue app hosting Modal.

kikuomax added a commit to kikuomax/buefy that referenced this issue Dec 3, 2023
- Quick fixes the issue that `useI18n` did not work in a setup script
  within the context of a programmatically opened `Modal`.
  `copyAppContext` helper function also copies the private field
  `__VUE_I18N_SYMBOL__` used by `vue-i18n`. However, we will face
  similar problems unless we generalize the problem and fix it.

issue ntohq#153
kikuomax added a commit that referenced this issue Dec 4, 2023
…programmatically opened Modal (#153) (#154)

* fix(lib): useI18n did not work in Modal

- Quick fixes the issue that `useI18n` did not work in a setup script
  within the context of a programmatically opened `Modal`.
  `copyAppContext` helper function also copies the private field
  `__VUE_I18N_SYMBOL__` used by `vue-i18n`. However, we will face
  similar problems unless we generalize the problem and fix it.

issue #153
@kikuomax
Copy link
Collaborator Author

This should have been closed by #154.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: ✅ Done
Development

No branches or pull requests

1 participant