Skip to content
New issue

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

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

Already on GitHub? # to your account

fix: labels on toggle buttons are now clickable #568

Merged
merged 1 commit into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Components/Button/Documentation/ButtonBase.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

The Base Button is intended for custom use cases. It renders children inside itself to facilitate many use cases.

Note that if you are looking for radio buttons, look in Components->Inputs -> Multiple Choice Form.
our Implementation of Radio Buttons are Toggle Buttons.

### Usage

```tsx
import {ButtonBase} from '@influxdata/clockface'
```
Expand Down
12 changes: 10 additions & 2 deletions src/Components/Inputs/Toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,17 @@ export const Toggle = forwardRef<ToggleRef, ToggleProps>(

const title = disabled ? disabledTitleText : titleText

// putting onClick handler on the containing div,
// so that clicking on the children will toggle as well
// (b/c of the explicit onclick handler, the 'for' linking the labels
// to the input does not toggle the button at all)
return (
<div className={toggleClass} style={style} ref={containerRef}>
<div
className={toggleClass}
style={style}
ref={containerRef}
onClick={handleClick}
>
<input
id={id}
ref={ref}
Expand All @@ -187,7 +196,6 @@ export const Toggle = forwardRef<ToggleRef, ToggleProps>(
onBlur={handleInputBlur}
htmlFor={id}
onFocus={handleInputFocus}
onClick={handleClick}
onKeyUp={handleKeyUp}
tabIndex={tabIndex}
className="cf-toggle--visual-input"
Expand Down