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

Calling focus on a disabled input should not fire focus event or change focus of active element #1563

Open
marchaos opened this issue Oct 10, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@marchaos
Copy link

Describe the bug
As per the spect (see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled#attribute_interactions), calling focus() on an input element that is disabled should fire focus or change the active element.

To Reproduce
Steps to reproduce the behavior:
Discovered when attempting to convert tests from jsdom to happy-dom

    it('input should not have focus if disabled', () => {
        props.disabled = true;
        renderComponent();

        screen.getByTestId('input').focus();

        expect(screen.getByTestId('input')).not.toHaveFocus();
    });

Expected behavior
Calling focus() when an input is disabled should not dispatch any events

@marchaos marchaos added the bug Something isn't working label Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant