fix: Icon button click should not de-select row in table widget (#8197)

This commit is contained in:
Vicky Bansal 2021-10-08 18:00:12 +05:30 committed by GitHub
parent 4fde9d63be
commit fdac6428b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 10 deletions

View File

@ -155,4 +155,15 @@ describe("Table Widget property pane feature validation", function() {
expect(someText).to.equal("Successful tobias.funke@reqres.in");
});
});
it("Table widget test on button icon click, row should not get deselected", () => {
cy.get(widgetsPage.tableIconBtn)
.last()
.click({ force: true });
cy.get(commonlocators.TextInside).should("have.text", "Tobias Funke");
//click icon button again
cy.get(widgetsPage.tableIconBtn)
.last()
.click({ force: true });
cy.get(commonlocators.TextInside).should("have.text", "Tobias Funke");
});
});

View File

@ -112,6 +112,7 @@
"toggleChartType": ".t--property-control-charttype .t--js-toggle",
"inputToggleOnClick": ".t--property-control-onclick div.CodeMirror-lines",
"tableBtn": ".t--draggable-tablewidget .bp3-button",
"tableIconBtn": ".t--draggable-tablewidget .bp3-icon",
"toastAction": ".Toastify__toast-container--top-right .t--toast-action",
"toastActionText": ".Toastify__toast-container--top-right .t--toast-action span",
"defaultColName": "[data-rbd-draggable-id='customColumn1'] input",

View File

@ -142,15 +142,15 @@ class TableWidget extends BaseWidget<TableWidgetProps, WidgetState> {
columnProperties,
originalIndex,
);
let isSelected = false;
if (this.props.multiRowSelection) {
isSelected =
Array.isArray(this.props.selectedRowIndices) &&
this.props.selectedRowIndices.includes(rowIndex);
} else {
isSelected = this.props.selectedRowIndex === rowIndex;
}
if (columnProperties.columnType === "button") {
let isSelected = false;
if (this.props.multiRowSelection) {
isSelected =
Array.isArray(this.props.selectedRowIndices) &&
this.props.selectedRowIndices.includes(rowIndex);
} else {
isSelected = this.props.selectedRowIndex === rowIndex;
}
const buttonProps = {
isSelected: isSelected,
onCommandClick: (action: string, onComplete: () => void) =>
@ -183,7 +183,6 @@ class TableWidget extends BaseWidget<TableWidgetProps, WidgetState> {
: undefined,
});
} else if (columnProperties.columnType === "image") {
const isSelected = !!props.row.isSelected;
const isCellVisible = cellProperties.isCellVisible ?? true;
const onClick = columnProperties.onClick
? () =>
@ -220,7 +219,7 @@ class TableWidget extends BaseWidget<TableWidgetProps, WidgetState> {
return renderMenuButton(menuButtonProps, isHidden, cellProperties);
} else if (columnProperties.columnType === "iconButton") {
const iconButtonProps = {
isSelected: !!props.row.isSelected,
isSelected: isSelected,
onCommandClick: (action: string, onComplete: () => void) =>
this.onCommandClick(rowIndex, action, onComplete),
columnActions: [