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

Blur event is not triggered on the current active element in the click helper #1032

Closed
helgablazhkun opened this issue May 24, 2021 · 3 comments

Comments

@helgablazhkun
Copy link
Contributor

Scenario:
Expected result:
GIVEN There are two elements on the form: focusable input and label (simple div).
AND Input element has focus
WHEN Click on the label occurs (via click test helper)
THEN Input gets blur event and loses its focus

Actual result:
Input doesn't get blur event and doesn't lose its focus

The root cause of the issue is that the blur event is not triggered on the current active element in the click helper in case if the clicked element is not focusable.
If the clicked element is focusable the previous active element gets blur event trough the focus helper.

Proposed solution: Add a call to blur for the case when the clicked element is not focusable.

Real world example: The issue is noticed in the integration test for dropdown component with Ember Power Select in the real application. When click occurs on the dropdown option (non-focusable element) then input doesn't lose its focus in the test but it does in the real application. So Click test helper has different behaviour with browser click.

@rwjblue
Copy link
Member

rwjblue commented May 25, 2021

Can you create a plain HTML demo showing the real world scenario you described (e.g. codepen with just a few lines of JS wiring up a blur event)?

I want to make sure that we properly emulate the events across all of our supported browsers.

@helgablazhkun
Copy link
Contributor Author

helgablazhkun commented May 25, 2021

Please use this example: https://codepen.io/helgablazhkun/pen/qBrjbzd
Events are logged into the console.

Update: Added disabled input to the codepen demo to test click on it as well

@helgablazhkun
Copy link
Contributor Author

Closed
#1033

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

No branches or pull requests

2 participants