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

Fixed EuiSuperDatePicker input focus. #3154

Merged
merged 15 commits into from
Apr 7, 2020
Merged

Conversation

ashikmeerankutty
Copy link
Contributor

@ashikmeerankutty ashikmeerankutty commented Mar 24, 2020

Summary

Fixes #2490
This was due to the tab component overriding the focus of the input. This was fixed by overriding the tab components focus when onMouseDown on input.

Before

before

After

after

Checklist

  • Check against all themes for compatibility in both light and dark modes
  • Checked in mobile
  • Checked in IE11 and Firefox
    - [ ] Props have proper autodocs
    - [ ] Added documentation examples
  • Added or updated jest tests
  • Checked for breaking changes and labeled appropriately
    - [ ] Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

@kibanamachine
Copy link

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@ashikmeerankutty ashikmeerankutty changed the title Fixed EuiSuperDatePicker requires two clicks into inputs within EuiPopovers after clicking non-input components within the TabPanel Fixed EuiSuperDatePicker input focus. Mar 24, 2020
@miukimiu miukimiu requested review from miukimiu and removed request for miukimiu March 24, 2020 13:25
Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think forcing focus via mouse down is the correct way to fix the issue. You mentioned that the tabs were stealing focus, we should probably address why they are stealing focus.

@ashikmeerankutty
Copy link
Contributor Author

ashikmeerankutty commented Mar 29, 2020

@cchaos Thanks for the review. On investigating, the issue was the focus event from the input is bubbled and the tab content divs on focus is called which in turn calls the focus on the tab button. It also found that this issue only occurs for input elements. I have fixed the issue by filtering the onFocus events from the INPUT elements. If the focus is from an input element the focus on the tab button is not called.

@cchaos cchaos requested review from thompsongl and removed request for thompsongl March 30, 2020 19:30
@cchaos
Copy link
Contributor

cchaos commented Mar 30, 2020

Hmm, I still don't think this solution is quite right. It's not general enough to allow any content to receive the focus like buttons or select elements. I think the problem lies where the focus is being listened for.

The divRef is the entire tabset plus its content. Really what the original focus stealing was for was to ensure that when a user focuses on the tabset the focus goes to the selected instead of first tab (when initialFocus = 'selected'). I think moving the focus ref to the EuiTabs would fix the problem

@ashikmeerankutty
Copy link
Contributor Author

@cchaos Thanks for the suggestion. By moving the focus to the ref to EuiTabs fixed the issue.

@cchaos
Copy link
Contributor

cchaos commented Apr 3, 2020

Jenkins test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3154/

expand={expand}
display={display}
size={size}
onFocus={this.initializeFocus}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ashikmeerankutty I talked with @chandlerprall and we came to the conclusion that the divRef is still need in order to allow tabbing through all of the tabs. But that it should also be move to <EuiTabs>. By doing so you'll most likely need to modify EuiTabs to forwardRef to the containing div.

Copy link
Contributor Author

@ashikmeerankutty ashikmeerankutty Apr 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cchaos Thanks for the comment. Moved divRef to EuiTabs. Do I need to rename divRef to tabRef for readability?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would help a lot. Perhaps even tabsRef (plural) so it's more obvious that it's on the whole EuiTabs component.

@cchaos
Copy link
Contributor

cchaos commented Apr 6, 2020

Jenkins test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3154/

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked through IE, FF, and Chrome and the original problem is fixed with IE still behaving correctly. 👍 🎉 Thank you @ashikmeerankutty , our Firefox users will be very appreciative!

I did notice that there is an existing bug where using the mouse to select a different tab than the initially selected, the focus should be on the one clicked not the one selected. I will log a new issue for this since it was not created by this PR.

CHANGELOG.md Outdated Show resolved Hide resolved
@cchaos
Copy link
Contributor

cchaos commented Apr 6, 2020

retest

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3154/

@cchaos
Copy link
Contributor

cchaos commented Apr 6, 2020

Hmm, possibly flakey?

retest

@cchaos
Copy link
Contributor

cchaos commented Apr 6, 2020

retest

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3154/

@cchaos cchaos merged commit c7edcfd into elastic:master Apr 7, 2020
@ashikmeerankutty ashikmeerankutty deleted the fix/tabs branch April 15, 2020 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants