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

Clicking on TAB and SHIFT+TAB should also fire a blur event #72

Open
RuslanZavacky opened this issue May 30, 2017 · 6 comments
Open

Clicking on TAB and SHIFT+TAB should also fire a blur event #72

RuslanZavacky opened this issue May 30, 2017 · 6 comments

Comments

@RuslanZavacky
Copy link

When firing a keyboard TAB event (eg. press TAB button). Browsers behavior is, to throw a keyboard event and also, blur the current document.activeElement.

Currently, we are not doing that in ember-native-dom-helpers. It caused a bit of confusion to understand what's going on, so I think it might be worth to add it as a default behavior.

Thoughts?

@cibernox
Copy link
Owner

This is tricky actually. If we want to replicate the browsers behaviour when using TAB, we should do it properly, which is not simple. I don't oppose tho, I just want to highlight what it would be required.

We'd need to have a special case for tab (and SHIFT + TAB) that gets the first focusable item after what what it's currently focused, or the first one if nothing is focused. This by itself has some tricky rules: all inputs, elements with contenteditable, buttons and links unless they have a negative tabindex. Also, if something has a positive tabindex, we need to obey it. Disabled inputs and elements don't count.

Also, this requires the concept of "what it's currently focused", so I think this feature would require the browser window to be focused for real.

I'm ok with the idea, but it is a hard one.

@RuslanZavacky
Copy link
Author

@cibernox yes, this was the thing that I was concerned about... making it right, is actually mimicking the whole browser tabbing behavior, which is definitely complex. If I am not mistaken, is we will use normal Event instead of KeyboardEvent, things should work. So the question is, maybe we can fake it until we make it somehow? :)

@cibernox
Copy link
Owner

we will use normal Event instead of KeyboardEvent

Can you explain this? I think that a KeyboardEvent is closer to "reality"

@RuslanZavacky
Copy link
Author

@cibernox yes it does. I tried to say that - looks like, using just a simple Event solves the issues, and tabbing works, while using keyboard event it doesn't. So maybe there is a way, how we can have a 'fallback' to the simple Event. But I am not exactly sure how we can implement it, without breaking stuff a lot :)

@cibernox
Copy link
Owner

Wait, you mean if that if you fire a generic Event instead of a KeyboardEvent the browser blurs the active element? Really? That makes no sense to me.

@RuslanZavacky
Copy link
Author

@cibernox before I'll say that, I'll verify it again :) I might've mistaken this behaviour yesterday with something else :)

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