question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Button retains mdc-ripple-upgraded--background-focused style even though it's not focused

See original GitHub issue

I have three buttons that I’m using as a search results view type button bank (grid view, list view, map view).

When a particular view type is active, the corresponding Button is marked as disabled so the user can’t reselect it (it’s already been applied).

Expected behaviour

When a user clicks an option, the button relating to that option should be highlighted, other buttons should lose their highlight.

Actual behaviour

Initial load with list view active: Screenshot 2019-06-07 at 15 51 40

I think that disabled is the wrong thing. What I really want is a a button group where the buttons work as a radio buttons (eg: https://getbootstrap.com/docs/4.1/components/buttons/#checkbox-and-radio-buttons) So my first problem with this is that the colours are wrong. The selected one should be highlighted, and the others should be secondary in this case.

It doesn’t feel like there’s a paradigm for that at the moment…?

After first click: Screenshot 2019-06-07 at 15 51 50

The selected button retains its focus style, even if I attribute focus to a different element on the screen.

After second click: Screenshot 2019-06-07 at 15 51 57

The first click-button still retains its focused style.

Code

        <div className="search-tools__format">
          <Button icon={<MaterialIcon icon="map" />} disabled={format === "map"} onClick={e => {changeViewFormat("map");}} />
          <Button icon={<MaterialIcon icon="view_list" />} disabled={format === "list"} onClick={e => {changeViewFormat("list");}} />
          <Button icon={<MaterialIcon icon="view_module" />} disabled={format === "grid"} onClick={e => {changeViewFormat("grid");}} />
        </div>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:18 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
TroyTaecommented, Jun 10, 2019

TBD This issue is fired when element’s disabled is being true after click. After click, element has mdc-ripple-upgraded--background-focused class. But blur event isn’t fired at disabled element, so this focus class is keep alive. There is need to think about how to solve this problem.

1reaction
adamsoffercommented, Dec 29, 2019

@moog16 This seems to unfortunately still be an issue ->

https://codesandbox.io/s/material-react-ripple-bug-muly9

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to remove focus around buttons on click - Stack Overflow
I found this Q and A on another page, and overriding the button focus style worked for me. This problem may be specific...
Read more >
Inconsistent behavior among browsers when clicking on buttons
I noticed browsers were inconsistent in how they handle a click on a button element. Some browsers choose to focus on the button....
Read more >
Refining focus styles with focus-visible - tempertemper
In lots of browsers, an item is considered focused when it is clicked with a pointing device like a mouse or trackpad. This...
Read more >
Help With Button Focus - AutoIt GUI Help and Support
Here is a basic GUI with some buttons that do nothing for demonstration. ... ENTER key, even when the button does not have...
Read more >
How to remove focus around buttons on click? - GeeksforGeeks
To remove focus around the button outline:none property is used. ... It does not take space from the width of an element like...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found