Skip to content

Commit

Permalink
fix disabled button click (#11617)
Browse files Browse the repository at this point in the history
## Description πŸ“
Fix clicking disabled delete button also collapsing/expanding the accordion. No changeset needed as this hasn't been released yet

## Target release date πŸ—“οΈ
2/11/15

## How to test πŸ§ͺ

### Prerequisites

(How to setup test environment)

- Have a LKE or LKE-E cluster set up with 1 node pool

### Verification steps

(How to verify changes)

- [ ] Go to a LKE or LKE-E cluster with only 1 node pool
- [ ] Click on the disabled delete pool button. The accordion should stay as is and not expand or collapse from the click
  • Loading branch information
hana-akamai authored Feb 5, 2025
1 parent 21e36b1 commit 0151722
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
27 changes: 24 additions & 3 deletions packages/manager/cypress/e2e/core/kubernetes/lke-update.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1614,20 +1614,41 @@ describe('LKE cluster updates', () => {
const mockCluster = kubernetesClusterFactory.build({
k8s_version: latestKubernetesVersion,
});
const mockSingleNodePool = mockNodePools[0];
mockGetCluster(mockCluster).as('getCluster');
mockGetClusterPools(mockCluster.id, mockNodePools).as('getNodePools');
mockGetClusterPools(mockCluster.id, [mockSingleNodePool]).as(
'getNodePools'
);

cy.visitWithLogin(`/kubernetes/clusters/${mockCluster.id}`);
cy.wait(['@getCluster', '@getNodePools']);

cy.get(`[data-qa-node-pool-id="${mockNodePools[0].id}"]`).within(() => {
cy.get(`[data-qa-node-pool-id="${mockSingleNodePool.id}"]`).within(() => {
// Accordion should be expanded by default
cy.get(`[data-qa-panel-summary]`).should(
'have.attr',
'aria-expanded',
'true'
);

// Click on a disabled button
cy.get('[data-testid="node-pool-actions"]')
.should('be.visible')
.within(() => {
ui.button
.findByTitle('Delete Pool')
.should('be.visible')
.should('be.disabled')
.click();
});

// Check that the accordion is still expanded
cy.get(`[data-qa-panel-summary]`).should(
'have.attr',
'aria-expanded',
'true'
);

// Click on an action button
cy.get('[data-testid="node-pool-actions"]')
.should('be.visible')
Expand All @@ -1652,7 +1673,7 @@ describe('LKE cluster updates', () => {
.click();
});

cy.get(`[data-qa-node-pool-id="${mockNodePools[0].id}"]`).within(() => {
cy.get(`[data-qa-node-pool-id="${mockSingleNodePool.id}"]`).within(() => {
// Check that the accordion is still expanded
cy.get(`[data-qa-panel-summary]`).should(
'have.attr',
Expand Down
3 changes: 3 additions & 0 deletions packages/manager/src/components/ActionMenu/ActionMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ export const ActionMenu = React.memo((props: ActionMenuProps) => {
handleClose(e);
a.onClick();
}
if (stopClickPropagation) {
e.stopPropagation();
}
}}
data-qa-action-menu-item={a.title}
data-testid={a.title}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export const NodePool = (props: Props) => {
disableFocusListener={!isOnlyNodePool}
disableHoverListener={!isOnlyNodePool}
disableTouchListener={!isOnlyNodePool}
onClick={(e) => e.stopPropagation()}
title="Clusters must contain at least one node pool."
>
<div>
Expand Down

0 comments on commit 0151722

Please sign in to comment.