Skip to content

Commit

Permalink
Fix string editor
Browse files Browse the repository at this point in the history
  • Loading branch information
dk981234 committed Dec 14, 2024
1 parent 8bb9797 commit 6db642b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/survey-creator-react/src/StringEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,18 @@ export class SurveyLocStringEditor extends CreatorModelElement<any, any> {
private get className() {
return this.baseModel.className(this.locString.renderedHtml);
}
private htmlValue = {
__html: this.locString?.renderedHtml
};
public render(): React.JSX.Element {
if (!this.locString) {
return null;
}
let control = null;
if (this.locString.hasHtml) {
const showText = this.baseModel.focused && this.baseModel.editAsText;
const htmlValue = { __html: showText ? null : this.locString.renderedHtml };
if(this.htmlValue.__html !== this.locString.renderedHtml) {
this.htmlValue = { __html: this.locString.renderedHtml };
}
control = (
<span
role="textbox"
Expand All @@ -141,13 +145,13 @@ export class SurveyLocStringEditor extends CreatorModelElement<any, any> {
aria-label={this.placeholder || "content editable"}
suppressContentEditableWarning={true}
// style={this.style}
dangerouslySetInnerHTML={htmlValue}
dangerouslySetInnerHTML={this.htmlValue}
onBlur={this.onBlur}
onFocus={this.onFocus}
onKeyDown={this.onKeyDown}
onMouseUp={this.onMouseUp}
onClick={this.edit}
>{showText ? this.locString.calculatedText : null}</span>
></span>
);
} else {
control = (
Expand Down Expand Up @@ -208,4 +212,4 @@ ReactElementFactory.Instance.registerElement(
(props) => {
return React.createElement(SurveyLocStringEditor, props);
}
);
);

0 comments on commit 6db642b

Please sign in to comment.