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

fix: solve incorrect type when dealing with value in list #3094

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jyling
Copy link
Contributor

@jyling jyling commented Sep 28, 2024

Description

Please include a summary of the changes and the related issues.
This fix solves the issue 3093 where the output coming from the dynamic form input has the wrong type. This lead to weird behaviour when selecting the options and also issue with updating the record on the admin UI.

My fix consists of overriding the value with the correct type, I'm unsure if this is a acceptable solution, but it does solve the issue.

For example.
I have a list of options from a custom field that contains numbers like calling code.
The options are meant to be strings of options. so it's configured like this

{
    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" }]
        }
    ]
}

When I select the first option, the output will become like this

["1"]

The issue arises when my form input is a list, and I want to add the second option, which will cause the first option to turn into a number, so it will become like this

[1, "60"].

if I change the first input again, it will become like this

["61", 60]

Breaking changes

Does this PR include any breaking changes we should be aware of?
I'm not very sure, is there any test that I can run ?

Screenshots

Before
image
After
image

You can add screenshots here if applicable.

Checklist

📌 Always:

  • I have set a clear title
  • My PR is small and contains a single feature
  • [] I have checked my own PR

👍 Most of the time:

  • I have added or updated test cases
  • I have updated the README if needed

Copy link

vercel bot commented Sep 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview Sep 30, 2024 1:14am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant