Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

fix(checkbox): enable name attribute #678

Merged
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
3 changes: 3 additions & 0 deletions packages/checkbox/index.tsx
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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