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

Custom Field number string value breaks if it's on select input #3093

Closed
jyling opened this issue Sep 28, 2024 · 2 comments
Closed

Custom Field number string value breaks if it's on select input #3093

jyling opened this issue Sep 28, 2024 · 2 comments
Labels
type: bug 🐛 Something isn't working

Comments

@jyling
Copy link
Contributor

jyling commented Sep 28, 2024

Describe the bug
I'm trying to implement a simple input to my channel where I can set a list of supported calling codes, such as 1, 60 and 61. but I encounter an issue where the input from the admin UI will send a number type instead of a string to the backend on one of the values.

I tried searching for an issue with this, but I could not find anything related to this issue.

To Reproduce
Steps to reproduce the behaviour:

  1. Add this to your channel's custom field
config.customFields.Channel.push({
    name: "supportedNumbers"
    type: "string",
    label: [{ languageCode: LanguageCode.en, value: "Supported Phone Number" }],
    ui: { component: "select-form-input" },
    list: true,
    options: [

        // Usually we get this list from a library, but we 
        // can hard code it for now
        {
            value: "1",
            label: [{ languageCode: LanguageCode.en, value: "US" }]
        },
        {
            value: "60",
            label: [{ languageCode: LanguageCode.en, value: "MY" }]
        },
        {
            value: "61",
            label: [{ languageCode: LanguageCode.en, value: "SG" }]
        }
    ]
})
  1. generate your migration
  2. open the admin UI and navigate to any channel config page
  3. you can see the custom field input looks weird
    image
  4. try add one input
  5. update, there's no issue so far, only ui bug
    image
  6. Now add another one, ui is still bugged
    image
  7. press update after making the changes
  8. See error (note: for testing purposes, I call my customfield as e)
    image
    image

Expected behavior
It should allow the US, SG or MY, and should not make one of the inputs into a number, it should be a string.

Environment (please complete the following information):

  • @vendure/core version: 3.0.3
  • Nodejs version: 18.2.3
  • Database (mysql/postgres etc): postgres 16

Additional context
My guts tell me it's one of those javascript weirdness that causes this issue, this is because if i change my input value to +1, instead of 1, the UI will work, and the bug won't appear.

@jyling jyling added the type: bug 🐛 Something isn't working label Sep 28, 2024
@jyling
Copy link
Contributor Author

jyling commented Sep 28, 2024

I'm going to attempting to solve the issue myself, will update if I have any updates.

@jyling
Copy link
Contributor Author

jyling commented Sep 28, 2024

Hi, I opened a pr over here #3094 I hope my solution will be suitable to the issue that I'm facing

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

1 participant