Skip to content

Commit d91b416

Browse files
committed
Fix property grid changes tab name when question's name is changing
1 parent 8e85bdc commit d91b416

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

packages/survey-creator-core/src/property-grid/property-grid-view-model.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ export class PropertyGridViewModel extends Base {
104104
let titleName = this.getTitle();
105105
this.selectedElementName = titleName;
106106
this.objectSelectionAction.tooltip = titleName;
107-
this.objectSelectionAction.title = this.propertyGridModel.showOneCategoryInPropertyGrid ? "" : titleName;
107+
if(!this.propertyGridModel.showOneCategoryInPropertyGrid) {
108+
this.objectSelectionAction.title = titleName;
109+
}
108110
}
109111
private getTitle(): string {
110112
var obj = this.getSelectedObj();

packages/survey-creator-core/tests/property-grid/property-grid-viewmodel.tests.ts

+26-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import {
55
PopupModel,
66
IAction,
77
QuestionMatrixDynamicModel,
8-
_setIsTouch
8+
_setIsTouch,
9+
QuestionTextModel
910
} from "survey-core";
1011
import { PropertyGridViewModel } from "../../src/property-grid/property-grid-view-model";
1112
export { PropertyGridEditorMatrix } from "../../src/property-grid/matrices";
1213
import { CreatorTester } from "../creator-tester";
1314
import { ObjectSelectorModel } from "../../src/property-grid/object-selector";
1415
import { settings } from "../../src/creator-settings";
16+
import { TabDesignerPlugin } from "../../src/components/tabs/designer-plugin";
1517

1618
test("Generate and update title correctly", () => {
1719
const creator = new CreatorTester();
@@ -191,4 +193,26 @@ test("Create the property grid survey on request", () => {
191193
const model = new PropertyGridViewModel(propertyGrid, creator);
192194
expect(model.getPropertyValue("survey")).toBeFalsy();
193195
expect(model.survey).toBeTruthy();
194-
});
196+
});
197+
198+
test("Object selector's title should be leaved unchanged when changing question's name - Bug#6699", () => {
199+
const creator = new CreatorTester();
200+
creator.JSON = {
201+
elements: [
202+
{
203+
type: "text",
204+
name: "question1"
205+
}
206+
]
207+
};
208+
const question = creator.survey.getQuestionByName("question1");
209+
creator.showOneCategoryInPropertyGrid = true;
210+
const propertyGridViewModel = (creator.getPlugin("designer") as TabDesignerPlugin).propertyGridViewModel;
211+
const selectorBarItem = propertyGridViewModel.objectSelectionAction;
212+
creator.selectElement(question);
213+
expect(selectorBarItem.title).toBe("General");
214+
expect(selectorBarItem.tooltip).toBe("question1");
215+
question.name = "question2";
216+
expect(selectorBarItem.title).toBe("General");
217+
expect(selectorBarItem.tooltip).toBe("question2");
218+
});

0 commit comments

Comments
 (0)