Skip to content

Commit

Permalink
fix(checkbox): enable name attribute (#678)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklasisraelsson authored and Matt Goo committed Feb 19, 2019
1 parent 9f93ef3 commit 2c77ab5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/checkbox/index.tsx
Expand Up @@ -33,6 +33,7 @@ export interface CheckboxProps extends Ripple.InjectedProps<HTMLDivElement, HTML
className?: string;
disabled?: boolean;
indeterminate?: boolean;
name?: string;
nativeControlId?: string;
onChange?: (evt: React.ChangeEvent<HTMLInputElement>) => void;
initRipple: (surface: HTMLDivElement, activator?: HTMLInputElement) => void;
Expand Down Expand Up @@ -171,6 +172,7 @@ export class Checkbox extends React.Component<CheckboxProps, CheckboxState> {
/* eslint-enable no-unused-vars */
disabled,
nativeControlId,
name,
...otherProps
} = this.props;

Expand All @@ -186,6 +188,7 @@ export class Checkbox extends React.Component<CheckboxProps, CheckboxState> {
checked={this.state.checked}
disabled={disabled}
aria-checked={this.state['aria-checked']}
name={name}
onChange={this.onChange}
rippleActivatorRef={this.inputElement}
/>
Expand Down
5 changes: 5 additions & 0 deletions test/unit/checkbox/index.test.tsx
Expand Up @@ -134,6 +134,11 @@ test('passes nativeControlId to NativeControl through props', () => {
assert.equal(wrapper.childAt(0).props().id, 'test-id');
});

test('passes name to NativeControl through props', () => {
const wrapper = shallow(<Checkbox name='test-name' />);
assert.equal(wrapper.childAt(0).props().name, 'test-name');
});

test('calls foundation.handleChange in native control props.onChange', () => {
const wrapper = shallow<Checkbox>(<Checkbox />);
const nativeControl = wrapper.childAt(0);
Expand Down

0 comments on commit 2c77ab5

Please sign in to comment.