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

Checkbox does not toggle #1014

Closed
psudarsa opened this issue Dec 10, 2016 · 4 comments
Closed

Checkbox does not toggle #1014

psudarsa opened this issue Dec 10, 2016 · 4 comments

Comments

@psudarsa
Copy link

I am using a semantic.react with typescript. Here is a simple example

export class SearchBar extends Component<{}, { status: boolean }> {

constructor() {
    super();
    this.state = { status: true };
}

public render() {
    return (
        <div className="sixteen column">

            <div className="ui attached segment">
                <Checkbox label="status" checked={this.state.status} onClick={() => this.updateStatus()}/>

            </div>
        </div>
    );
}

private updateStatus() {
    this.setState({ status: !this.state.status });
}

}

the div seems to be generated always with readonly tag
image

I have tried this with onChange also. Am i doing something wrong here ?

@psudarsa
Copy link
Author

Seems like this is a less issue with the packaged themes. I will move this out to the other branch.

@JoBurgard
Copy link

I seem to have the same problem. As soon as I add a function to onClick or onChange the checkbox doesn't toggle anymore.

@levithomason
Copy link
Member

Here's a working example:

http://react.semantic-ui.com/modules/checkbox#remote-control

@colinweight
Copy link

To elaborate on what @psudarsa said, for me this was a css issue as I was using a custom theme and the css resulting from the Gulp build.

Despite the actual input having the class of hidden, being readonly and not showing as checked, the javascript is actually working as it should. The problem is missing css. When using a custom theme, the builder is not including custom checkbox overrides.

To fix this I copied the overrides from themes/default/modules/checkbox.overrides to site/modules/checkbox.overrides and the check mark appeared. You may need to copy/paste the code from/to a different location depending on your theming needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants