Support focus outputs on button-toggle, slide-toggle etc.
For all custom components with an underlying input we should support a focus / blur event on the component host.
Since the most of those components are wrapped inside of <label> element, the focus / blur events will fire like on each click.
- http://codepen.io/DevVersion/pen/Vmwmvd?editors=1111
I think in this case the focus | blur events will not make any big sense, because those are kind of fired like the click event.
The problem here is, that the label always redirects focus to the underlying input (and the user always clicks on the label)
I appreciate that the slide-toggle has a focus class .md-slide-toggle-focused that I can use to style the component when it is focused. Maybe something similar could work for button-toggle.
Is there a way to focus a <md-button-toggle> by default? I have tried giving it md-button-toggle-checked class but doesn't work.
I propose having the behavior consistent with the input text control, that is having the focus and blur events fire, like in this Plunker https://plnkr.co/edit/h2OyULESEcE6IBzdAAIG from #4817
We need to use the conditional Angular ngClass on a parent when a child control was focused or blurred.
I thought more about this and also chatted with @crisbeto briefly about this.
We don't really think that it would make sense to add such an output. The reason for this that we would end-up proxying likely every output, which native DOM elements have.
For example: (click), (mouseover) etc.
I would like to close this issue but waiting for @jelbourn's thoughts still.
The focus and blur events are special because they don't bubble. There are others as well, but none especially relevant to our components. However, I don't see what you couldn't accomplish with the combination of a "focus class" and use of focusin and focusout.
Thanks guys, replacing (focus) -> (focusin), (blur) -> (focusout) got the job done.
<md-input-container floatPlaceholder="always"
[ngClass]="{'mat-focused':focusedChannels}">
<input mdInput id="channels" style="display: none">
<md-checkbox #checkboxChannel
(focusin)="focusedChannels=true" (focusout)="focusedChannels=false">
Checkbox Label
</md-checkbox>
</md-input-container>
Going to close that issue, because focusin and focusout seem to be reasonable solutions. It's difficult to re-implement/fire proper focus events with the underlying input, because the <label> element causes the focus to jump between the <label> and <input> element.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.