Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

click() doesn't retry when a button's parent element becomes actionable after being disabled. #30655

Open
Ray-Frost opened this issue Nov 20, 2024 · 1 comment

Comments

@Ray-Frost
Copy link

Current behavior

If a button's parent element, such as a fieldset, becomes actionable after being disabled, the click() associated with the button will be skipped instead of retried.

<fieldset disabled id="test-fieldset">
  <button id="test-button" type="button">
    Test click
  </button>
</fieldset>

const fieldsetTimer = setTimeout(() => {
  document.getElementById('test-fieldset').disabled = false;
}, 500);

CleanShot 2024-11-20 at 13 39 27@2x

Desired behavior

click() should automatically wait for the element to reach an actionable state as the document described

Test code to reproduce

it('Test click', function () {
  cy.get('#test-button').click();
});

Cypress Version

13.15.0

Node version

20.14.0

Operating System

MacOS 15.1

Debug Logs

No response

Other

This issue might be related to this condition, given PR #28807

@ryanthemanuel
Copy link
Collaborator

Hi @Ray-Frost, thanks for reporting this. I can recreate this as you described, the click succeeds immediately but the click event handlers never fire.

It appears that #28807 got us half way to what is ideal. It ensured that click events wouldn't fire when a parent was disabled; however, you are right we should actually retry (and eventually fail) in case the parent eventually becomes enabled. I'd also need to check, but I'm not sure this logic works properly if there are multiple levels of nesting.

In the meantime, I believe you could work around this by doing something like:

cy.get('#test-button').should('be.enabled').click()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants