-
Notifications
You must be signed in to change notification settings - Fork 545
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
refactor(App): remove default locale handling #2760
base: v3
Are you sure you want to change the base?
refactor(App): remove default locale handling #2760
Conversation
commit: |
This is a valid point. Only you need to delete the comment in |
Got it, I'll remove the comment |
@@ -37,12 +36,12 @@ const configProviderProps = useForwardProps(reactivePick(props, 'scrollBody')) | |||
const tooltipProps = toRef(() => props.tooltip) | |||
const toasterProps = toRef(() => props.toaster) | |||
const locale = computed(() => props.locale || en) | |||
const locale = toRef(() => props.locale) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is toRef
here necessary? locale
is already reactive (since it is a prop)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can remove it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, its because the localeContextInjectionKey
accepts ref type, you can see it at:
export const localeContextInjectionKey: InjectionKey<Ref<Locale | undefined>> = Symbol('nuxt-ui.locale-context') |
And about replacement from
computed
to toRef
just only for consistency like the code above (tooltipProps
and toasterProps
), or should I revert to the computed
then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I've got a problem here, the reactivity does working for dir
but for any attributes for aria-*
doesn't updating. For example:
And here's the updated code:
App.vue
provide(localeContextInjectionKey, props.locale)
useLocale.ts
export const localeContextInjectionKey: InjectionKey<Locale | undefined> = Symbol('nuxt-ui.locale-context') const _useLocale = (localeOverrides?: Locale | undefined) => { const locale = localeOverrides || inject(localeContextInjectionKey, undefined)! return buildLocaleContext(computed(() => locale || en)) }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benjamincanac I'll see what the problem might be today or tomorrow and I'll report back
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep the toRef
on App
component since it works as expected, similar to what's described in the PR π€
π Linked issue
Resolves #2759
β Type of change
π Description
This PR removes the default locale handling from the
App
component, as this functionality is already managed by theuseLocale
composable at:ui/src/runtime/composables/useLocale.ts
Line 16 in ba874c9
Additionally, the value of
dir
prop is set to be optional because current default language is English, and Radix Vue already provides a defaultltr
value for it: https://www.radix-vue.com/utilities/config-provider.html#config-provider-1Example results of
locale
prop fromApp
component:undefined
valuefr
valuear
valueπ Checklist