Skip to content

Strings set in a custom control that use custom lang file show as undefined when first rendered but work on second render #1577

Open
@breagol37

Description

@breagol37

Description:

If you create a custom control that references strings via mi18n that are set in a custom .lang file.

All works fine in the builder and strings are set correctly, however if you then render the form the strings that are set show as undefined.
If you then render a second time strings will set correctly.

Below test custom control in builder
image

Then when rendered

image

When rendered a second time show as normal.

image

It will also work as expected if you render the form first before adding the custom control then adding the control and rendering.

Example of the ref in code to one of the strings.

image

And the i18n options passed to render in the main index (for this test)
image

In debugging it seemed that the html is displayed before the applyLanguage function has finished.

Environment Details:

  • formBuilder Version: 3.19.7
  • Browser: Chrome
  • OS: Windows

Expected Behavior

Strings should be applied from the custom lang file on first render.

Actual Behavior

Strings do not get applied from the custom .land file until second render.

Steps to Reproduce

Create a custom .lang file and add the details to the i18n location.
Create a custom control and add refs to any custom strings in your custom lang file using controlClass.mi18n("yourCustomStringKey").
Start Form builder and add your control to your form (All strings added as expected)
Render the form (Custom strings used show as undefined)
Render again (Strings now show as expected)

You can also.
In form builder have either blank or any other controls (NOT your custom) added.
Render
Go back to builder and add your custom control
Strings in your control show as expected as its a second render.

Metadata

Metadata

Assignees

No one assigned

    Labels

    custom controlIssue relating to a custom control

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions