Skip to content

Commit

Permalink
Pages Collection Editor - The Trash Bin (Remove) button is unavailabl…
Browse files Browse the repository at this point in the history
…e when you use the Add Page button fix Bug#6645
  • Loading branch information
andrewtelnov committed Feb 26, 2025
1 parent 0ebc8bd commit 34e48cf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
3 changes: 0 additions & 3 deletions packages/survey-creator-core/src/property-grid/matrices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -670,9 +670,6 @@ export class PropertyGridEditorMatrixPages extends PropertyGridEditorMatrix {
public fit(prop: JsonObjectProperty): boolean {
return prop.type == "surveypages";
}
protected addItem(creator: ISurveyCreatorOptions, obj: Base, question: QuestionMatrixDynamicModel) {
(creator as CreatorBase).addPage(undefined, false);
}
protected getColumnClassName(obj: Base, prop: JsonObjectProperty): string {
return "page@" + obj.getType();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import {
ComponentCollection,
QuestionBooleanModel,
QuestionRadiogroupModel,
PageModel
PageModel,
ActionContainer
} from "survey-core";
import {
EmptySurveyCreatorOptions,
Expand Down Expand Up @@ -3684,4 +3685,29 @@ test("Undo for deleting validator in multiple text item, Bug#6295", () => {
creator.undo();
expect(item1.validators).toHaveLength(1);
expect(matrix.visibleRows).toHaveLength(1);
});
});
test("Pages Collection Editor - The Trash Bin (Remove) button is unavailable when you use the Add Page button Bug#6645", () => {
const creator = new CreatorTester();
const propertyGrid = new PropertyGridModelTester(creator.survey, creator);
const pagesQuestion = <QuestionMatrixDynamicModel>propertyGrid.survey.getQuestionByName("pages");
expect(pagesQuestion.visibleRows).toHaveLength(0);
const action = pagesQuestion.getTitleActions().filter(action => action.id === "add-item")[0];
expect(action).toBeTruthy();
action.action();
action.action();
expect(pagesQuestion.visibleRows).toHaveLength(2);

const rows = pagesQuestion.renderedTable.rows;
expect(rows[0].isErrorsRow).toBeFalsy();
expect(rows[0].hasEndActions).toBeTruthy();
let cell = rows[0].cells[rows[0].cells.length - 1];
expect(cell.isActionsCell).toBeTruthy();
let container = <ActionContainer>cell.item.value;
expect(container.getActionById("remove-row")).toBeTruthy();
expect(rows[2].isErrorsRow).toBeFalsy();
expect(rows[2].hasEndActions).toBeTruthy();
cell = rows[2].cells[rows[2].cells.length - 1];
expect(cell.isActionsCell).toBeTruthy();
container = <ActionContainer>cell.item.value;
expect(container.getActionById("remove-row")).toBeTruthy();
});

0 comments on commit 34e48cf

Please sign in to comment.