Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
… Creator - Property Grid - Cannot read properties of undefined (reading 'imageLink')
  • Loading branch information
tsv2013 committed Jan 20, 2025
1 parent a77ca17 commit c22d04f
Show file tree
Hide file tree
Showing 8 changed files with 472 additions and 445 deletions.

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions packages/survey-creator-core/src/components/page.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Action, ActionContainer, classesToSelector, ComputedUpdater, DragOrClickHelper, DragTypeOverMeEnum, IAction, IElement, PageModel, property, QuestionRowModel, SurveyElement, settings as SurveySettings } from "survey-core";
import { SurveyCreatorModel } from "../creator-base";
import { IPortableMouseEvent } from "../utils/events";
import { SurveyElementAdornerBase } from "./action-container-view-model";
import { SurveyElementAdornerBase } from "./survey-element";
import { getLocString } from "../editorLocalization";
import { SurveyHelper } from "../survey-helper";
import { settings } from "../creator-settings";
Expand Down Expand Up @@ -129,10 +129,10 @@ export class PageAdorner extends SurveyElementAdornerBase<PageModel> {
}
@property({
onSet(val, target: PageAdorner, prevVal) {
if(val != prevVal) {
if (val != prevVal) {
target.updateShowPlaceholder();
target.updateActionsProperties();
if(val && target.surveyElement) {
if (val && target.surveyElement) {
target.addGhostPageSubsribes(target.surveyElement);
}
}
Expand Down Expand Up @@ -326,7 +326,7 @@ export class PageAdorner extends SurveyElementAdornerBase<PageModel> {
if (cssClasses.pageRow) return [].slice.call(this.rootElement?.querySelectorAll(`:scope .svc-page__footer, :scope ${classesToSelector(this.surveyElement.cssRoot)} > .svc-row`));
return null;
}
public onPageSelected() {}
public onPageSelected() { }
protected getAllowDragging(options: any): boolean {
return this.creator.allowDragPages && super.getAllowDragging(options);
}
Expand Down
25 changes: 16 additions & 9 deletions packages/survey-creator-core/src/components/question-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,25 @@ export class QuestionImageAdornerViewModel extends QuestionAdornerViewModel {
) {
super(creator, surveyElement, templateData);
this.isEmptyImageLink = !this.question.imageLink;
this.surveyElement.registerFunctionOnPropertyValueChanged("imageLink", this.imageLinkValueChangedHandler, "imageLinkValueChanged");
(this.surveyElement as QuestionImageModel).locImageLink.onStringChanged.add(this.imageLinkValueChangedHandler);
this.initFilePresentationModel();
}

protected detachElement(surveyElement: SurveyElement): void {
if (surveyElement) {
surveyElement.unRegisterFunctionOnPropertyValueChanged("imageLink", "imageLinkValueChanged");
(surveyElement as QuestionImageModel).locImageLink.onStringChanged.remove(this.imageLinkValueChangedHandler);
}
super.detachElement(this.element);
}
protected attachElement(surveyElement: SurveyElement): void {
super.attachElement(surveyElement);
if (surveyElement) {
surveyElement.registerFunctionOnPropertyValueChanged("imageLink", this.imageLinkValueChangedHandler, "imageLinkValueChanged");
(surveyElement as QuestionImageModel).locImageLink.onStringChanged.add(this.imageLinkValueChangedHandler);
}
}


@property({ defaultValue: false }) isUploading;
@property({ defaultValue: false }) isEmptyImageLink;

Expand Down Expand Up @@ -100,11 +114,4 @@ export class QuestionImageAdornerViewModel extends QuestionAdornerViewModel {
.append(super.css())
.append("svc-question__content--loading", this.isUploading).toString();
}
public dispose(): void {
if (this.surveyElement) {
this.surveyElement.unRegisterFunctionOnPropertyValueChanged("imageLink", "imageLinkValueChanged");
(this.surveyElement as QuestionImageModel).locImageLink.onStringChanged.remove(this.imageLinkValueChangedHandler);
}
super.dispose();
}
}
5 changes: 3 additions & 2 deletions packages/survey-creator-core/src/components/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ import {
isPropertyVisible,
propertyExists,
} from "../utils/creator-utils";
import { SurveyElementActionContainer, SurveyElementAdornerBase } from "./action-container-view-model";
import { SurveyElementActionContainer } from "./action-container-view-model";
require("./question.scss");
import { settings } from "../creator-settings";
import { StringEditorConnector, StringItemsNavigatorBase } from "./string-editor";
import { DragDropSurveyElements, isPanelDynamic } from "../survey-elements";
import { QuestionToolbox, QuestionToolboxItem } from "../toolbox";
import { isUndefined } from "lodash";
import { listComponentCss } from "./list-theme";
import { SurveyElementAdornerBase } from "./survey-element";

export interface QuestionBannerParams {
text: string;
Expand Down Expand Up @@ -680,7 +681,7 @@ export class QuestionAdornerViewModel extends SurveyElementAdornerBase {
cssClasses: listComponentCss,
});
newAction.popupModel.onVisibilityChanged.add((_: PopupModel, opt: { model: PopupModel, isVisible: boolean }) => {
if(opt.isVisible) {
if (opt.isVisible) {
const listModel = newAction.popupModel.contentComponentData.model;
options.updateListModel(listModel);
}
Expand Down
Loading

0 comments on commit c22d04f

Please sign in to comment.