surveyjs / survey-creator

Scalable open-source survey software to generate dynamic JSON-driven forms within your JavaScript application. The form builder features a drag-and-drop UI, CSS Theme Editor, and GUI for conditional logic and form branching.
https://surveyjs.io/open-source
Other
910 stars 372 forks source link

Get an error when progressBarType property from survey #5296

Closed chancesmith closed 8 months ago

chancesmith commented 8 months ago

Are you requesting a feature, reporting a bug or ask a question?

bug

What is the current behavior?

When removing the survey progressBarType property, an error occurs. Uncaught TypeError: Cannot read properties of undefined (reading 'toLowerCase')

Screen Shot 2024-03-02 at 7 00 48 PM

What is the expected behavior?

I expect the Progress Bar Type property to be removed from the property grid.

How would you reproduce the current behavior (if this is a bug)?

Call Serializer.removeProperty("survey", "progressBarType");

Provide the test code and the tested page URL (if applicable)

Tested page URL: https://codepen.io/chancesmith/pen/dyLPdOY

Test code

Survey.Serializer.removeProperty("survey", "progressBarType");
function SurveyCreatorRenderComponent() {
    const options = {
        showLogicTab: true
    };
    const creator = new SurveyCreator.SurveyCreator(options);
    creator.JSON = {};
    return (<SurveyCreator.SurveyCreatorComponent creator={creator} />);
}

const root = ReactDOM.createRoot(document.getElementById("surveyCreatorContainer"));
root.render(<SurveyCreatorRenderComponent />);

Specify your

andrewtelnov commented 8 months ago

@chancesmith It is more safe to hide the property instead of removing it. It is very likely that we don't check that this property may not exist in our code in Creator. Please use the following code:

const prop = Survey.Serializer.findProperty("survey", "progressBarType");
prop.visible = false;

Thank you, Andrew

JaneSjs commented 8 months ago

@chancesmith, You can also use the creator.onShowingProperty event to hide unwanted settings. For more information, please visit the following demo: Hide a Category from the Property Grid.

Should you have any further questions, please feel free to reactivate this thread.

Thanks