[BUG] Prevent rendering issue with the SelectComponent when it has focus#316
[BUG] Prevent rendering issue with the SelectComponent when it has focus#316
Conversation
7342d55 to
893373b
Compare
|
Anything in afterRender can't be causing the double-render error. By definition that error requires something is synchronously changes during the rendering phase (which is in the render queue) The other two places here that actions queue is used look like they could be a more relevant fix though, under the presumption a focus event is triggered synchronously during rendering. They seem more germane? |
|
@cyril-sf Can you point out (privately if need be) where are the issues in our application that this fixes? |
|
I spent some time trying to better understand when the focusin/focusout events are fired (in general, not in Ember specifically). It looks like it is possible for these to interleave if the DOM changes in a way that modifies focus, for instance by removing the focused element from the DOM, or calling I'm not clear on what moving the popover's |
bantic
left a comment
There was a problem hiding this comment.
Seems good. I wish we had a better understanding of why the popover's didInsertElement work needs to have its queue changed to actions, but not a blocking concern.
Perhaps in the future we can remove the hasFocus property altogether in favor of CSS that uses the :focus/:focus-within selector.
|
@bantic Agreed. What seems to not make possible to rely on CSS at the moment is the way we decide if the https://github.com/Addepar/ember-widgets/blob/master/addon/components/select-component.js#L543-L552 @mixonic reading the |
* focus events may fire from child elements (like buttons) may fire during teardown of the DOM (un-rendering). These should be ignored by a parent component which only cared about input focus anyway. * Move work in the popover out of `didInsertElement` and into the `afterRender` queue.
| selectComponent = this.$()[0]; | ||
| if (selectComponent.contains(activeElem) || selectComponent === activeElem) { | ||
| return this.set('hasFocus', true); | ||
| setFocus: function(targetElement = document.activeElement) { |
There was a problem hiding this comment.
When does setFocus not have an argument?
This fix aims to remove the following deprecation:
The
SelectComponentsets a specific class when it is focused (ember-widgets/app/templates/select.hbs
Line 3 in ebcc0e2
It's failing in our application, but I haven't been successful at writing a test to cover the case in the library. Based on the deprecated state of the library and the fact that the problem was caught somewhere else, I decided to not invest more time on it.