How to keep focus on custom Polymer element when interacting with focusable elements contained within it?

亡梦爱人 提交于 2019-12-12 01:55:38

问题


I have created a custom Polymer element which extends paper-fab.

The element contains other elements such as paper-button and paper-input within it. These elements are initially hidden meaning, you just see a FAB.

With the custom element implemented on a different page, when it is clicked it gains focus therefore the custom element changes shape from a circle to a rectangle and shows the paper-button and paper-input elements within it.

When you click away from the custom element such as on a different part of the page, the element changes back to a circle from a rectangle as it no longer has focus. However when interacting with the paper-buttons and paper-input, these elements gain focus and therefore the custom element loses focus and changes shape back to a circle which is not intended here. When interacting with the elements contained within the custom element, the custom element should remain a rectangle; showing and allow interaction with the elements contained within it. When clicking away from the entire custom element, it should change back to a circle and hide the elements within it.

Please see the JS Bin to see how I currently have this set up: http://jsbin.com/wuxuhowavi/1/edit?html,output

来源:https://stackoverflow.com/questions/27028978/how-to-keep-focus-on-custom-polymer-element-when-interacting-with-focusable-elem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!