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

Admin UI: Metrics widget doesn't show numbers on hover: Invalid language tag: en- #2896

Closed
martijnvdbrug opened this issue Jun 13, 2024 · 5 comments
Assignees
Labels
type: bug 🐛 Something isn't working

Comments

@martijnvdbrug
Copy link
Collaborator

martijnvdbrug commented Jun 13, 2024

Describe the bug
The metrics chart isn't showing the values (€) on hover.

To Reproduce
Steps to reproduce the behavior:

  1. Go to the dashboard in Brave
  2. Hover over the chart to view actual numbers. Numbers are not showing
  3. See error in console:
RangeError: Invalid language tag: en-
    at new DateTimeFormat (<anonymous>)
    at vendure-admin-ui-core.mjs:19285:35
    at k.addEventListener.passive (vendure-admin-ui-core.mjs:19270:21)
    at H.invokeTask (zone.js:402:31)
    at Object.onInvokeTask (core.mjs:11070:33)
    at H.invokeTask (zone.js:401:60)
    at k.runTask (zone.js:173:47)
    at Z.invokeTask [as invoke] (zone.js:483:34)
    at q (zone.js:1631:18)
    at tt (zone.js:1662:29)

Expected behavior
A clear and concise description of what you expected to happen.

Environment (please complete the following information):

  • @vendure/core version: 2.1.5
  • Nodejs version 18
  • Database (mysql/postgres etc): MySQL
  • Browser: Brave

Additional context
Add any other context about the problem here.

@martijnvdbrug martijnvdbrug added the type: bug 🐛 Something isn't working label Jun 13, 2024
@michaelbromley
Copy link
Member

From the error message, it appears that the error originates on this line

const locale = `${uiState.language}-${uiState.locale}`;

and uiState.locale has not been explicitly set, and also no "defaultLocale" is specified in the vendure-ui-config.json file, so is using the default value of ''.

In fact, I'm not even sure how you get into this state under normal usage, because even if no "defaultLocale" is set, then the Admin UI should take the locale from the browser:

return navigator.language.split('-')[1]?.toUpperCase();

Can you provide any more context around how to reproduce this? I'm unable to.

@martijnvdbrug
Copy link
Collaborator Author

martijnvdbrug commented Jun 26, 2024

@michaelbromley I am using Brave browser, but without the built-in JS blocker (disabled it for the Vendure admin). It should be Chrome basicly, but maybe they do hide somet locale info or something? I will look into it

This issue occurs on all my client's dashboards, without doing anything weird:

  1. Open /admin
  2. Login
  3. Hover the metrics chart
  4. No numbers are shown on hover and the above error is shown in the browser logs
    (Also just verified on V2.2.6)

Firefox works fine.

@martijnvdbrug
Copy link
Collaborator Author

So, prints out en for navigator.language, so navigator.language.split('-')[1]?.toUpperCase(); yeidls undefined in Brave. Not sure why this is the case...

image

@martijnvdbrug
Copy link
Collaborator Author

martijnvdbrug commented Aug 7, 2024

Although this might not be expected output, it is valid according to its specs:

@martijnvdbrug
Copy link
Collaborator Author

I am going to close this, as it is very specific to Brave and my personal settings. If anyone encounters this issue, change your first language in Brave settings to English (United States) instead of English.

image

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

No branches or pull requests

2 participants