Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

<md-button>: cancelling button tap/click does not remove :focus style #1423

Closed
mwilc0x opened this issue Feb 7, 2015 · 7 comments
Closed

Comments

@mwilc0x
Copy link

mwilc0x commented Feb 7, 2015

Hi, first thanks for this project, great stuff.

Noticing this behavior with md-buttons.. please let me know if this is expected behavior or if an enhancement that might create a better UX.

If user clicks a button but drags their finger/cursor off the button and cancels the tap/click, the :focus style is not removed from the button. So like in the examples on your demo page, the button will remain with darker box shadow and darker button shade.

@mwilc0x
Copy link
Author

mwilc0x commented Feb 7, 2015

Actually, looks like it is a result of trying to use <md-button> inside <ion-nav-button>

    <ion-nav-buttons side="left">
        <md-button class="md-raised" ng-click="close()">Close</md-button>
    </ion-nav-buttons>

Is there a recommended way for mashing up these two?

I have a <md-button> inside an <ion-item> and it is working great, the focus is removed correctly.

        <ion-list>
            <div ng-repeat="foo in baz.bar">
                <ion-item class="item-stable">

                    <div class="row">

                        <div class="col-30">
                            <md-button class="md-raised" ng-click="selectFoo($index)">Open</md-button>
                            <md-button class="md-raised" ng-click="copyFoo($index)">Copy</md-button>
                        </div>

                    </div>

                </ion-item>
            </div>

        </ion-list>
``

@marcysutton
Copy link
Contributor

This is a known issue, and it has to do with how buttons natively stay focused after you click them. @robertmesserle @rschmukler I'm remembering we talked about a fix for this briefly last week. #556

@rschmukler
Copy link
Contributor

@marcysutton I think our best bet might be a pure JS implementation of focus that then applies a md-focused class which is auto removed after a timeout. Pressing a key re-applies it to the last known element (or, the next one)...

We could then style off of md-focused and do away with how the browser handles it

@marcysutton
Copy link
Contributor

That sounds smart to me, seeing how much of a pain it is cross-browser.

@marcysutton
Copy link
Contributor

Except if you are using the keyboard, focus should stay until you blur the element, not after a timeout. The challenging part will be discerning mouse clicks from keyboard clicks (button elements trigger click events from the keyboard).

@rschmukler
Copy link
Contributor

Could we use the absence of e.keyCode to identify it as a mouse click?

@marcysutton
Copy link
Contributor

You don't get keyCodes from a click event, only keypress. They always come back as 0. Here's a sandbox I use to test stuff like this: http://codepen.io/marcysutton/pen/YPxrLd

@rschmukler rschmukler added the needs: team discussion This issue requires a decision from the team before moving forward. label Feb 7, 2015
@ThomasBurleson ThomasBurleson modified the milestone: 0.8.0 Feb 17, 2015
@robertmesserle robertmesserle modified the milestones: 0.8.0, 0.9.0 Feb 19, 2015
marcysutton pushed a commit that referenced this issue Feb 20, 2015
@ajoslin ajoslin added the in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs label Feb 20, 2015
@robertmesserle robertmesserle removed needs: team discussion This issue requires a decision from the team before moving forward. in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs labels Mar 25, 2015
@robertmesserle robertmesserle modified the milestones: Backlog, 0.9.0 Mar 25, 2015
marcysutton pushed a commit that referenced this issue Apr 10, 2015
marcysutton pushed a commit that referenced this issue Apr 10, 2015
@Splaktar Splaktar removed this from the - Backlog milestone Feb 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants