-
Notifications
You must be signed in to change notification settings - Fork 776
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
It is impossible to override question error rendering for a particular survey #8189
Comments
We decided to implement an ability to override question error component rendering |
tsv2013
changed the title
It is impossible to override the survey rendering in the Survey Preview
It is impossible to override question error rendering in the Survey Preview
Apr 26, 2024
tsv2013
changed the title
It is impossible to override question error rendering in the Survey Preview
It is impossible to override question error rendering
Apr 26, 2024
andrewtelnov
changed the title
It is impossible to override question error rendering
It is impossible to override question error rendering for a particular survey
Apr 26, 2024
tsv2013
pushed a commit
that referenced
this issue
Apr 26, 2024
…g for a particular survey - try to fix f-tests
tsv2013
pushed a commit
that referenced
this issue
Apr 26, 2024
…g for a particular survey - passed context element
tsv2013
added a commit
that referenced
this issue
Apr 27, 2024
…particular survey (#8191) * Implemented #8189 - Allow to override question error rendering for a particular survey * Work for #8189 - It is impossible to override question error rendering for a particular survey - try to fix f-tests * Fixed Vue lint * Work for #8189 - It is impossible to override question error rendering for a particular survey - passed context element --------- Co-authored-by: tsv2013 <tsv2013@noreply.github.com>
I've implemented functionality allowing to override question error rendering for any survey. In order to do it it survey creator preview you need to use the declare custom component for error visualization: class CustomQuestionError extends React.Component {
render() {
const owner = this.props.error.errorOwner;
const question = !!owner && owner.isQuestion ? owner : undefined;
const clickMeFunc = () => alert(!!question && !question.isEmpty() ? question.value : "No value");
return (
<div>
<div>A custom text</div>
<span className={this.props.cssClasses.error.icon || undefined} aria-hidden="true" />
<span className={this.props.cssClasses.error.item || undefined}>
<SurveyReact.SurveyLocStringViewer locStr={this.props.error.locText} />
</span>
<button onClick={clickMeFunc}>Click Me...</button>
</div>
);
}
}
SurveyReact.ReactElementFactory.Instance.registerElement(
"my-preview-error",
(props) => {
return React.createElement(CustomQuestionError, props);
}
); and set the creator.onSurveyInstanceCreated.add((sender, options) => {
if (options.reason = "preview") {
options.survey.questionErrorComponent = "my-preview-error";
}
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The question was asked in SurveyJS support forum: Customize Error message in preview screen of survey creator.
The text was updated successfully, but these errors were encountered: