vendure-ecommerce / vendure

The commerce platform with customization in its DNA.
https://www.vendure.io
Other
5.61k stars 995 forks source link

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

Open jyling opened 2 hours ago

jyling commented 2 hours ago

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-input-component" },
    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" }]
        }
    ]
    })
  2. generate your migration
  3. open the admin UI and navigate to any channel config page
  4. you can see the custom field input looks weird image
  5. try add one input
  6. update, there's no issue so far, only ui bug image
  7. Now add another one, ui is still bugged image
  8. press update after making the changes
  9. 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):

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 commented 2 hours ago

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