payload icon indicating copy to clipboard operation
payload copied to clipboard

Locale Dropdown is empty on first login

Open nexflo opened this issue 1 year ago • 5 comments

Link to reproduction

No response

Payload Version

3.62

Node Version

18.17.2

Next.js Version

latest

Describe the Bug

I'm logging into payload cms. I click around, all is fine. Trying to change the locale, that field is empty. Only upon "full" fresh the locales is populated. image

Reproduction Steps

Login to a fresh session. Dont refresh. Click the locale dropdown.

Adapters and Plugins

No response

nexflo avatar Aug 15 '24 12:08 nexflo

Hey @nexflo - could you please send me how you are defining your locales in your payload config?

Thank you!

PatrikKozak avatar Aug 15 '24 13:08 PatrikKozak

Hey @PatrikKozak certainly:

We created a locales.ts with the following the content:

export const locales = [
  {
    label: "Default (English)",
    code: "en",
  },
  {
    label: "Austria",
    code: "de-AT",
  },
  {
    label: "Belgium (Dutch)",
    code: "nl-BE",
  },
  {
    label: "Belgium (French)",
    code: "fr-BE",
  },
  {
    label: "Croatia",
    code: "hr-HR",
  },
  {
    label: "Czech Republic",
    code: "cs-CZ",
  },
  {
    label: "Denmark",
    code: "da-DK",
  },
  {
    label: "Estonia",
    code: "et-EE",
  },
  {
    label: "Finland",
    code: "fi-FI",
  },
  {
    label: "France",
    code: "fr-FR",
  },
  {
    label: "Germany",
    code: "de-DE",
  },
  {
    label: "Greece",
    code: "el-GR",
  },
  {
    label: "Hungary",
    code: "hu-HU",
  },
  {
    label: "Italy",
    code: "it-IT",
  },
  {
    label: "Latvia",
    code: "lv-LV",
  },
  {
    label: "Lithuania",
    code: "lt-LT",
  },
  {
    label: "Netherlands",
    code: "nl-NL",
  },
  {
    label: "Norway",
    code: "no-NO",
  },
  {
    label: "Poland",
    code: "pl-PL",
  },
  {
    label: "Portugal",
    code: "pt-PT",
  },
  {
    label: "Romania",
    code: "ro-RO",
  },
  {
    label: "Slovakia",
    code: "sk-SK",
  },
  {
    label: "Slovenia",
    code: "sl-SI",
  },
  {
    label: "Spain",
    code: "es-ES",
  },
  {
    label: "Switzerland (German)",
    code: "de-CH",
  },
  {
    label: "Switzerland (French)",
    code: "fr-CH",
  },
  {
    label: "Ukraine",
    code: "uk-UA",
  },
  {
    label: "United Kingdom",
    code: "en-GB",
  },
];

this gets imported in the payload config: import { locales } from "@/locales";

and added as such:

  localization: {
    locales,
    defaultLocale: "en",
    fallback: true,
  },

nexflo avatar Aug 15 '24 13:08 nexflo

@nexflo thank you! I'll be taking a look into this!

PatrikKozak avatar Aug 15 '24 13:08 PatrikKozak

@nexflo Can you do me a favor and update your project to the latest beta version (v3.0.0-beta.81) and give this another go?

On a fresh new project on latest, I'm unable to reproduce the behavior - we've made some updates to localization since v3.0.0-beta.62 so the issue may have already been fixed.

Let me know how that goes!

PatrikKozak avatar Aug 15 '24 13:08 PatrikKozak

@PatrikKozak thanks for looking into this! @nexflo forgot to mention an important part to this, we are customizing the options based on the current user. It seems that directly after login useAuth doesn’t work in our custom component.

I’ve created a repro for it with auto login disabled. https://github.com/carlcs/payload/tree/repro/no-user-after-login

carlcs avatar Aug 16 '24 10:08 carlcs

It’s fixed https://github.com/payloadcms/payload/pull/7727

carlcs avatar Aug 26 '24 09:08 carlcs

As mentioned by @carlcs - #7727 fixes this issue - closing this issue for now.

PatrikKozak avatar Aug 26 '24 17:08 PatrikKozak

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.

github-actions[bot] avatar Sep 06 '24 20:09 github-actions[bot]