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.

Switches not responding to clicks

See original GitHub issue

Problem Description

I’m using material-ui in a Meteor 1.3.1 application via npm. So far, all components I’ve used (Dialoges, Tabs, Icons, GridLists, Selects, TextFields, Popovers, Menus, Lists, Snackbars, Buttons, LeftNav) work like a charm. But a simple plain Checkbox does not respond to any clicks. It doesn’t matter whether controlled or uncontrolled. It doesn’t matter where i put it. It simply does not respond to any user interaction. The onCheck function never gets called. I can control the Checkbox with a button thought. For example, here I can check and uncheck the Checkbox by clicking on the FlatButton, but none of the other components (including the CheckBox itself) respond to clicks:

import React, {Component, PropTypes} from 'react';
import Checkbox from 'material-ui/lib/checkbox';
import Toggle from 'material-ui/lib/toggle';
import RadioButton from 'material-ui/lib/radio-button';
import RadioButtonGroup from 'material-ui/lib/radio-button-group';
import FlatButton from 'material-ui/lib/flat-button';

class Example extends Component {

    constructor(props) {

        super(props);

        this.state = {
            check: false
        };

        this._toggleCheck = (evt, isInputChecked) => {
            evt.preventDefault();
            this.setState({
                check: !this.state.check
            });
        };
    }

    render() {
        return (
            <div style={{maxWidth: 250}}>
                <FlatButton
                    label="Check"
                    onTouchTap={this._toggleCheck}
                />
                <Checkbox
                    checked={this.state.check}
                    onCheck={this._toggleCheck}
                    label="Checkbox"
                    style={{marginBottom: 16}}
                />
                <Toggle
                    label="Toggle"
                    style={{marginBottom: 16}}
                />
                <RadioButtonGroup name="shipSpeed" defaultSelected="not_light">
                    <RadioButton
                        value="light"
                        label="Simple"
                        style={{marginBottom: 16}}
                    />
                    <RadioButton
                        value="not_light"
                        label="Selected by default"
                        style={{marginBottom: 16}}
                    />
                </RadioButtonGroup>
            </div>
        );
    }
}

I’m lost here. Am I missing something? Any help would be much appreciated. Thanks!

Versions

  • Material-UI: 0.15.0-alpha.2
  • React: 0.14.8
  • Browser: Tested on Chrome and Firefox

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
jschliebercommented, Aug 5, 2016

The problem persists, but I figured it’s probably a conflict with the MaterializeCSS library, which is also used in this particular project. Unfortunately I didn’t have the time to check and to create a repro. I won’t have time before september as I am working on a different project right now.

Thanks for your help.

1reaction
Evilcat325commented, Jul 8, 2016

this is actually a easy issue. check this react documentation Potential Issues With Checkboxes and Radio Buttons

If you ever use event.perventDefault(), you need to setTimeout the setState for your case


this._toggleCheck = (evt, isInputChecked) => {
            evt.preventDefault();
            setTimeout( () => this.setState({
                check: !this.state.check
            }));
        };
Read more comments on GitHub >

github_iconTop Results From Across the Web

Switches not responding to clicks · Issue #3951 · mui/material-ui
Problem Description I'm using material-ui in a Meteor 1.3.1 application via npm. So far, all components I've used (Dialoges, Tabs, Icons, ...
Read more >
How to Fix the Left Click Mouse Button Not Working on ...
It could be the reason that the left click is not working. Similarly, a program update might have caused the issue. Go to...
Read more >
Buttons or Switches Are Not Responding or Respond Incorrectly
If the touch screen is registering as being pressed, then it may cause the buttons to act unresponsive. This step can be skipped...
Read more >
Left clicker on my logitech m170 is not responding to clicks ...
one thing you can try is to open up and check on the buttons and microswitches. check for any dry solder joints or...
Read more >
Mouse Left-Click Button Not Working? Here's How to Fix It
On both Windows 10 and 7, head to Control Panel > Hardware and Sound > Mouse. Ensure the “Turn on ClickLock” option is...
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