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

onBlur has inconsistent behavior. #418

Open
lmotioc opened this issue Aug 14, 2020 · 8 comments · May be fixed by #425
Open

onBlur has inconsistent behavior. #418

lmotioc opened this issue Aug 14, 2020 · 8 comments · May be fixed by #425
Labels

Comments

@lmotioc
Copy link

lmotioc commented Aug 14, 2020

Describe the bug
On Blur doesn't get triggered on focus out.
When a selected option is removed with the 'x'button onBlur isn't triggered, but when it is removed from the dropdown, on blur is triggered.

To Reproduce
CodeSandbox here with a console.log attached to onBlur.

  • focus in and focus out the select, on blur doesn't get triggered. (navigating with tab)
  • remove a selected option from the control (using the x button) on blur doesn't get triggered, but when you uncheck a selected option, onBlur gets triggered.

Expected behavior
onBlur to be triggered on focus out.
onBlur to be triggered when removing a component with the x button

Environment (please complete the following information):

  • Browser [e.g. chrome v84, firefox v78]
@mrchief
Copy link
Collaborator

mrchief commented Aug 24, 2020

I'm a little blurry on the onBlur 😄

I remember adding those in order for the component to work with forms like Formik or redux-forms. The idea was that onBlur would be fired when user clicks anywhere outside of the component. This would be consistent with native web controls.

onBlur to be triggered when removing a component with the x button

This should not trigger onBlur because the user can still be inside the component (especially in case of multiselect). Happy to be hear your thoughts.

@lmotioc
Copy link
Author

lmotioc commented Aug 25, 2020

The idea was that onBlur would be fired when user clicks anywhere outside of the component.

I agree. And I also need the onBlur for validation.

However, it dos not get triggered when you click outside. It gets triggered when you close the dropdown, it don't make any difference if the select is still focused or not. In case the select is still focused (e.g. for removing some of the selected items) when you actually leave the whole input, the onBlur does not get triggered.

@mrchief
Copy link
Collaborator

mrchief commented Aug 25, 2020

However, it dos not get triggered when you click outside. It gets triggered when you close the dropdown

Clicking outside should close the dropdown. Are you able to reproduce this in the CodeSandbox?

@lmotioc
Copy link
Author

lmotioc commented Aug 28, 2020

yep, but there is this case:

  • Initial state: select component has some values selected, the dropdown in closed, the component is out of focus.
  • step 1: user removes one of the selected items from the component. Component should now be on focus. the drop-down does not get triggered.
  • step 2: user clicks somewhere outside the component. component loses focus.
    Outcome: onBlur doesn't get triggered.
    Expected: onBlur gets triggered (i need the onBlur to trigger for the form to be re-validated)

So what i am trying to say is that the component can be on focus -off focus even if the dropdown is not triggered. does it make sense?

@mrchief
Copy link
Collaborator

mrchief commented Aug 28, 2020

Yes, I agree with you that that should be the case.

@mrchief mrchief added the bug label Aug 28, 2020
@lmotioc
Copy link
Author

lmotioc commented Aug 31, 2020

is it ok if i'll try to fix this? i'm not to sure what's the workflow here. 😄

@mrchief
Copy link
Collaborator

mrchief commented Sep 9, 2020

@lmotioc yes, have a go at it!

@lmotioc lmotioc linked a pull request Sep 16, 2020 that will close this issue
5 tasks
@github-actions
Copy link

github-actions bot commented Dec 1, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Dec 1, 2021
@mrchief mrchief removed the stale label Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants