From ff5ee958b8107d76d9f32660b6bd528e10d857ac Mon Sep 17 00:00:00 2001 From: Aleksey Novikov Date: Wed, 11 Dec 2024 09:58:41 +0300 Subject: [PATCH] #6210 Questions lock button is reset on tab change (#6212) Fixes #6210 --- .../src/components/tabs/designer.ts | 1 + .../src/expand-collapse-manager.ts | 3 +++ .../tests/tabs/designer.test.ts | 16 ++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/packages/survey-creator-core/src/components/tabs/designer.ts b/packages/survey-creator-core/src/components/tabs/designer.ts index 2dd0bcc71c..78c4d08c04 100644 --- a/packages/survey-creator-core/src/components/tabs/designer.ts +++ b/packages/survey-creator-core/src/components/tabs/designer.ts @@ -164,6 +164,7 @@ export class TabDesignerViewModel extends Base { locTooltipName: "ed.lockQuestionsTooltip", iconName: "icon-questionlock-24x24", iconSize: "auto", + active: this.creator.expandCollapseManager.questionsLocked, visible: new ComputedUpdater(() => this.creator.expandCollapseButtonVisibility != "never"), action: (action) => { action.active = !action.active; diff --git a/packages/survey-creator-core/src/expand-collapse-manager.ts b/packages/survey-creator-core/src/expand-collapse-manager.ts index 0273fb6514..ed1ff58d82 100644 --- a/packages/survey-creator-core/src/expand-collapse-manager.ts +++ b/packages/survey-creator-core/src/expand-collapse-manager.ts @@ -12,6 +12,9 @@ export class ExpandCollapseManager { this.updateCollapsed(elements || this.getCollapsableElements(), isCollapsed, reason); } + public get questionsLocked() { + return this._lockQuestions; + } public lockQuestions(locked: boolean) { this._lockQuestions = locked; } diff --git a/packages/survey-creator-core/tests/tabs/designer.test.ts b/packages/survey-creator-core/tests/tabs/designer.test.ts index 0c7f5d118f..9755ba2927 100644 --- a/packages/survey-creator-core/tests/tabs/designer.test.ts +++ b/packages/survey-creator-core/tests/tabs/designer.test.ts @@ -578,6 +578,22 @@ test("Check adorners lock questions for expand/collapse all", (): any => { expect(questionAdorner.collapsed).toBeFalsy(); }); +test("Check lock questions action on tab change", (): any => { + surveySettings.animationEnabled = false; + const creator = new CreatorTester(); + creator.expandCollapseButtonVisibility = "onhover"; + const designerPlugin = ( + creator.getPlugin("designer") + ); + const lockQuestions = designerPlugin.model.surfaceToolbar.getActionById("lockQuestions"); + lockQuestions.action(lockQuestions); + expect(lockQuestions.active).toBeTruthy(); + designerPlugin.deactivate(); + designerPlugin.activate(); + const lockQuestionsNew = designerPlugin.model.surfaceToolbar.getActionById("lockQuestions"); + expect(lockQuestionsNew.active).toBeTruthy(); +}); + test("expand/collapse event and expand all", () => { surveySettings.animationEnabled = false; const creator = new CreatorTester();