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

Unable to hide maskSettings items when creating a Specialized Question type #5843

Open doelgonzo opened 2 months ago

doelgonzo commented 2 months ago

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

Bug/Question

What is the current behavior?

The documentation here indicates that End users cannot break the functionality because the Property Grid hides the questionJSON object properties., but when I set some of these properties they still appear in the property grid (see test code). It's possible I'm doing something wrong, but I understand it that this should work this way. My gut says it's related to these being nested values, but I don't know how to get around it.

I also tried:

inheritBaseProps: ["maskSettings:max","maskSettings:min","maskSettings:decimalSeparator","maskSettings:thousandsSeparator", "maskSettings:allowNegativeValues"]

and it made no difference. Any guidance is welcome. Also, the console.log below prints out base properties but none of the maskSettings-related ones...

What is the expected behavior?

They are hidden, or I have a programatic way to hide these properties.

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

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

Test code

export const registerNumberInput = () => {
   const existingQuestion = ComponentCollection.Instance.getCustomQuestionByName(
    CustomField.NumberInput
  );

  // Register the NumericInput model with the ElementFactory
  if (!existingQuestion) {
    ComponentCollection.Instance.add({
      name: CustomField.NumberInput,
      iconName: CustomField.NumberInput,
      title: "Number Input",
      questionJSON: {
        type: "text",
        inputType: "text",
        maskType: "numeric",
        maskSettings: {
          saveMaskedValue: false,
          precision: 0,
        },
      },
      inheritBaseProps: ["maskSettings"],
    });
  }

  console.log(
    ComponentCollection.Instance.getCustomQuestionByName(
      CustomField.NumberInput
    )
  );
};

Specify your

JaneSjs commented 2 months ago

Hello, You set inheritBaseProps: ["maskSettings"], therefore, Mask Settings appear in a property grid. If you wish to define mask settings but make them unavailable in a property grid, update your specialized question definition and remove the inheritBaseProps attribute.

 ComponentCollection.Instance.add({
      name: "custom-number-input",
      title: "Number Input",
      questionJSON: {
        type: "text",
        inputType: "text",
        maskType: "numeric",
        maskSettings: {
          saveMaskedValue: false,
          precision: 0,
        },
      }
});

Let me know if you have any questions.

doelgonzo commented 2 months ago

@JaneSjs Is there a way to make maskSettings.saveMaskedValue or maskSettings.precision not appear on on the property grid but have the others within maskSettings still appear?