Skip to content

Commit

Permalink
Move code to matrix rendredTable (#8978)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov authored Oct 25, 2024
1 parent 363ac7c commit 73ecee8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
15 changes: 10 additions & 5 deletions packages/survey-core/src/question_matrixdropdownrendered.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,7 @@ export class QuestionMatrixDropdownRenderedTable extends Base {
this.rows.splice(rowIndex, removeCount);
this.updateShowTableAndAddRow();
}
public onDetailPanelChangeVisibility(
row: MatrixDropdownRowModelBase,
isShowing: boolean
) {
public onDetailPanelChangeVisibility(row: MatrixDropdownRowModelBase, isShowing: boolean): void {
const rowIndex = this.getRenderedRowIndex(row);
if (rowIndex < 0) return;
let currentIndex = rowIndex;
Expand All @@ -460,7 +457,15 @@ export class QuestionMatrixDropdownRenderedTable extends Base {
this.rows.splice(panelRowIndex, 1);
}
}
public getRenderedRowIndex(row: MatrixDropdownRowModelBase): number {
public focusActionCell(row: MatrixDropdownRowModelBase, actionCellIndex: number): void {
let row2Focus = this.rows[this.rows.length - 1];
if (this.matrix.isColumnLayoutHorizontal) {
const nextRenderedRowIndex = this.getRenderedRowIndex(row);
row2Focus = this.rows[nextRenderedRowIndex];
}
row2Focus?.focusCell(actionCellIndex);
}
private getRenderedRowIndex(row: MatrixDropdownRowModelBase): number {
for (var i = 0; i < this.rows.length; i++) {
if (this.rows[i].row == row) return i;
}
Expand Down
9 changes: 2 additions & 7 deletions packages/survey-core/src/question_matrixdynamic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -597,15 +597,10 @@ export class QuestionMatrixDynamicModel extends QuestionMatrixDropdownModelBase
this.removeRow(value, undefined, () => {
const rowCount = this.visibleRows.length;
const nextIndex = index >= rowCount ? rowCount - 1 : index;
const nextRow = this.visibleRows[nextIndex];
const nextRow = nextIndex > -1 ? this.visibleRows[nextIndex] : undefined;
setTimeout(() => {
if (nextRow) {
let row2Focus = this.renderedTable.rows[this.renderedTable.rows.length - 1];
if (this.isColumnLayoutHorizontal) {
const nextRenderedRowIndex = this.renderedTable.getRenderedRowIndex(nextRow);
row2Focus = this.renderedTable.rows[nextRenderedRowIndex];
}
row2Focus?.focusCell(this.getActionCellIndex(nextRow));
this.renderedTable.focusActionCell(nextRow, this.getActionCellIndex(nextRow));
} else {
this.focusAddBUtton();
}
Expand Down

0 comments on commit 73ecee8

Please sign in to comment.