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

Popups and Tooltips steal focus from input fields #1324

Closed
dgolds opened this issue Feb 13, 2017 · 5 comments · Fixed by #1341
Closed

Popups and Tooltips steal focus from input fields #1324

dgolds opened this issue Feb 13, 2017 · 5 comments · Fixed by #1341
Assignees
Labels

Comments

@dgolds
Copy link

dgolds commented Feb 13, 2017

Steps

  1. A page with inputs and Popups. Focus on an input then mouseover an item with a popup.tooltip

Expected Result

  1. Mousing over items with popups/tooltips should not steal focus from the input since the user can easily knock a mouse/trackpad during typing
  2. Note that this is what happens with semantic-ui

Actual Result

  1. The input loses focus

Version

0.64.8

Testcase

Fork this to show the issue: http://codepen.io/levithomason/pen/ZpBaJX

@levithomason
Copy link
Member

levithomason commented Feb 13, 2017

This was introduced in #1154, setting focus on the Portal when opened to allow keyboard navigation. We've had other issues with this approach as well:

Given that we now also have the issue of focus stolen on open, I think it is clear that we need to nix this feature. There is no possible way to know when it is appropriate to set/restore focus to/from a Portal.

If user's need focus onMount, they will have to set it manually. The use cases for this are far fewer than the use case of not wanting focus to change.

TL;DR

This feature should be removed.

@iamdanthedev
Copy link

iamdanthedev commented Feb 14, 2017

The problem is, that if let's say a popup should render a component which sets focus on it's child in componentDidMount, the popup steals focus almost immediately :( At the same time onOpen and onMount popup events happen earlier that the popup content is rendered..

browser.js?13f9:123 semanticUIReact:portal handleTriggerClick() - open +2s
browser.js?13f9:123 semanticUIReact:portal open() +1ms
browser.js?13f9:123 semanticUIReact:popup handleOpen() +1ms

///// onOpen
browser.js?13f9:123 Eatalizer:RecipeEditor onOpen() +2ms

browser.js?13f9:123 semanticUIReact:portal componentDidUpdate() +2ms
browser.js?13f9:123 semanticUIReact:portal renderPortal() +1ms
browser.js?13f9:123 semanticUIReact:portal mountPortal() +1ms
browser.js?13f9:123 semanticUIReact:popup handlePortalMount() +2ms

///// onMount
browser.js?13f9:123 Eatalizer:RecipeEditor onMount() +1ms

browser.js?13f9:123 semanticUIReact:dropdown componentWillMount() +37ms
browser.js?13f9:123 semanticUIReact:dropdown setValue() +2ms
browser.js?13f9:123 semanticUIReact:dropdown value +6ms large
browser.js?13f9:123 semanticUIReact:dropdown render() +5ms
browser.js?13f9:123 semanticUIReact:dropdown props +2ms Object {options: Array[16], defaultValue: "large", selection: true, additionLabel: "Add ", additionPosition: "top"…}
browser.js?13f9:123 semanticUIReact:dropdown state +3ms Object {open: undefined, value: "large", selectedLabel: undefined, searchQuery: "", selectedIndex: 6}
browser.js?13f9:123 semanticUIReact:dropdown renderHiddenInput() +3ms
browser.js?13f9:123 semanticUIReact:dropdown name:      undefined +3ms
browser.js?13f9:123 semanticUIReact:dropdown selection: true +5ms
browser.js?13f9:123 semanticUIReact:dropdown value:     large +2ms
browser.js?13f9:123 semanticUIReact:dropdown renderLabels() +4ms
browser.js?13f9:123 semanticUIReact:button render icon && !label: +51ms Object {classes: "ui green icon button"}

///// Me setting focus
browser.js?13f9:123 Eatalizer:PopupEditorContent componentDidMount() +5ms

browser.js?13f9:123 semanticUIReact:popup popupMounted() +17ms
browser.js?13f9:123 semanticUIReact:popup portal props: +3ms Object {openOnTriggerClick: true, closeOnTriggerClick: true, closeOnDocumentClick: true}
browser.js?13f9:123 semanticUIReact:portal componentDidUpdate() +5ms
browser.js?13f9:123 semanticUIReact:portal renderPortal() +0ms
browser.js?13f9:123 semanticUIReact:dropdown componentWillReceiveProps() +24ms
browser.js?13f9:123 semanticUIReact:dropdown to props: +3ms Object {}
browser.js?13f9:123 semanticUIReact:button render icon && !label: +7ms Object {classes: "ui green icon button"}

@iamdanthedev
Copy link

#1326

@levithomason levithomason self-assigned this Feb 17, 2017
@levithomason
Copy link
Member

PR for the original issue coming, we'll address the additional items raised in #1326 separately.

@levithomason
Copy link
Member

Released in [email protected]

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.

3 participants