Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firefox onClick not working in button #13957

Closed
michaelgriffithus opened this issue Dec 19, 2018 · 5 comments
Closed

Firefox onClick not working in button #13957

michaelgriffithus opened this issue Dec 19, 2018 · 5 comments
Labels
component: ButtonBase support: question

Comments

@michaelgriffithus
Copy link

@michaelgriffithus michaelgriffithus commented Dec 19, 2018

I have a simple react application that is using Material-UI components. The application menu drawer doesn't appear in FF 60.4 but works fine in Chrome.

If I change the state of the drawer in the developers toolbox the drawer appears. Its like the menu icon onClick event handler isn't firing: https://codesandbox.io/s/wo29099yvl

Any help would be appreciated, thanks in advance!

@oliviertassinari oliviertassinari added the support: question label Dec 19, 2018
@oliviertassinari oliviertassinari changed the title MenuIcon onClick Event not firing in FF 60.4 Firefox onClick issue in button Dec 19, 2018
@oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Dec 19, 2018

@michaelgriffithus Move the onClick listener from the SVG to the icon button.
It seems to be an issue with Firefox. Here is a simpler reproduction:

import React from 'react';

class NavDrawer extends React.Component {
  render() {
    return (
      <button>
        <svg
          onClick={() => {
            console.log('wtf');
          }}
        >
          <path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z" />
        </svg>
      </button>
    );
  }
}

export default NavDrawer;

The matter was also discussed in https://stackoverflow.com/questions/26402033/missing-click-event-for-span-inside-button-element-on-firefox.

@oliviertassinari oliviertassinari added the component: ButtonBase label Dec 19, 2018
@michaelgriffithus
Copy link
Author

@michaelgriffithus michaelgriffithus commented Dec 20, 2018

Thank you @oliviertassinari

@oliviertassinari oliviertassinari changed the title Firefox onClick issue in button Firefox onClick not working in button Jan 12, 2019
douglasnaphas added a commit to douglasnaphas/madliberationjs that referenced this issue Jan 12, 2019
This was cleared by by this comment
mui/material-ui#13461 (comment)
 and the relevant issue
mui/material-ui#13957.

I had to move the onClick to the button from the thing below the button.

It seems to work now in Firefox.

madliberation-96
douglasnaphas added a commit to douglasnaphas/madliberationjs that referenced this issue Mar 25, 2019
Firefox seems to need onClick to be at the Button level, not on
components within the Button.

mui/material-ui#13957
https://stackoverflow.com/questions/26402033/missing-click-event-for-span-inside-button-element-on-firefox

madliberation-105
@tonyjara
Copy link

@tonyjara tonyjara commented Nov 12, 2020

Warning still showing up and this is no longer a problem in FF, is there a way to mute this warning? Im on Material UI Core 4.11
Screenshot 2020-11-11 232219

@oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Nov 12, 2020

@tonyjara See #22804 for why it's still relevant. The description of the warning was changed in v5.

@jpfiorilla
Copy link

@jpfiorilla jpfiorilla commented Jun 28, 2021

Hello, I am on this error page because I am attempting to add a callback to MUI Autocomplete's closeIcon, eg:

<Autocomplete closeIcon={<Close fontSize="small" onClick={onClear} />} />

Wrapping the <Close /> in an IconButton informs me that I am putting a button inside another button. Autocomplete's onClose refers to a different function and is not related to the closeIcon.

Is there any way to add a callback to the CloseIcon?

Akhil-Reddy-Challa added a commit to Akhil-Reddy-Challa/whats-app-web-clone that referenced this issue Sep 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: ButtonBase support: question
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants