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
911 stars 373 forks source link

Unable to set a custom name #485

Closed sudiptochoudhury closed 5 years ago

sudiptochoudhury commented 5 years ago

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

Bug

What is the current behavior?

Unable to set a custom name to a question.

What is the expected behavior?

Ability to set custom names for questions.

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

  1. Go to https://surveyjs.io/Survey/Builder/
  2. Add a question (e.g., Single Input)
  3. Edit the question
  4. The value for "Name" field is shown as "question1". Change it to "first_name"
  5. Click ok
  6. Edit the question again
  7. The value for "Name" field still shows "question1" instead of "first_name"

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

Tested page URL: https://surveyjs.io/Survey/Builder/

Specify your

andrewtelnov commented 5 years ago

@sudiptochoudhury If you are changing the question.name in question directly, via in-place editing (using our adorners), then you are changing the question.title. I have just tried to change question name via property grid and question editor, it works as expected.

Thank you, Andrew

tsv2013 commented 5 years ago

You can set the inplaceEditForValues editor property to true to turn on inplace editing for values.

sudiptochoudhury commented 5 years ago

@andrewtelnov. I am not sure but I am not trying to change the title. I will come to later on whether question.title or question.name. That concern is secondary for now. The main concern is "the change is not saving". The popup in the user interface that comes up when I click edit button shows a field whose label is shown as "Name". There is another field in that popup, whose label is shown as "Title". So, I think if the UI is not badly conceived, then it's pretty clear from the user interface labels, that one refers to "Name" and another refers to "Title". Let's forget about all these names. Issue is simpler. Here are the steps to reproduce as images:

image image image image image

I was also wondering whether the value in Local Storage is getting changed, no it is not as you can see in the image below, the "name" property has not changed! image

sudiptochoudhury commented 5 years ago

@tsv2013 The current issue is not about editing in-place, nor about which variable stores it. I want to change value via the Edit popup and the value is not getting stored.

andrewtelnov commented 5 years ago

@sudiptochoudhury I have tried it with several browsers and it works fine in all of them. Probably something wrong with local storage in your browser. Could you please try this example?

Thank you, Andrew

sudiptochoudhury commented 5 years ago

@andrewtelnov The example you have just provided works correctly in the same browser.

andrewtelnov commented 5 years ago

@sudiptochoudhury It means that somehow the localstorage doesn't work correctly on your browser and it rollbacks the changes. I have no idea why. I am seeing this for the first time. Could you please try to create a survey in our Service area (it is completely free, but you would have to register)? It stores Survey JSON in azure database instead of local storage.

Thank you, Andrew

sudiptochoudhury commented 5 years ago

@andrewtelnov You may be right. But I in my own implementation I am not using local storage or can not find any thing in the local storage. Not sure if SurveyJS automatically uses LocalStorage or not. However, I did one more investigation. I tried onPropertyValueChanging event listener and in your example whenever I change the name it get this even triggered. But not triggering in my implementation. It is triggering for other items like for "is required" or "is visible" settings.

I need to mention one thing, my implementation uses

 editor = new SurveyEditor.SurveyEditor(null);

and then render after defining event listeners:

editor.render("editorElement", editorOptions);

Can it make the difference?

andrewtelnov commented 5 years ago

@sudiptochoudhury We use localstorage on our web page and do not use it in our libraries. It means that the problem in you code onPropertyValueChanging. This event allows to discard changes, for example. You may show your code on this event then.

Thank you, Andrew

andrewtelnov commented 5 years ago

@sudiptochoudhury As for your question. Here is the updated plunker with render function. You may try to recreate the problem in the plunker so we will be able to find out the reason of this behavior.

Thank you, Andrew