Skip to content

Commit

Permalink
ADCIO-3308) fix: fix checkbox submit issue (#48)
Browse files Browse the repository at this point in the history
* fix: fix checkbox submit issue

* refactor: set default type attribute

---------

Co-authored-by: dev-redo <[email protected]>
  • Loading branch information
dev-redo and dev-redo committed Apr 23, 2024
1 parent 1c0203a commit 3f287ac
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/components/Checkbox/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
import { ButtonHTMLAttributes } from 'react';

import styled from '@emotion/styled';

import Icon from '../Icon';
import { B3 } from '../Text';
import { color } from '../styles';

export interface CheckboxProps {
export interface CheckboxProps extends ButtonHTMLAttributes<HTMLButtonElement> {
selected: boolean;
onSelect: () => void;
disabled?: boolean;
label?: string;
}

const CHECKBOX_SIZE = 16;

export function Checkbox({ selected, onSelect, disabled, label }: CheckboxProps) {
export function Checkbox({
selected,
onSelect,
disabled,
label,
type = 'button',
...props
}: CheckboxProps) {
return (
<Container onClick={onSelect} aria-selected={selected} disabled={disabled}>
<Container
onClick={onSelect}
aria-selected={selected}
disabled={disabled}
type={type}
{...props}
>
<IconContainer
tabIndex={!label && !disabled ? 0 : -1}
disabled={disabled}
Expand Down

0 comments on commit 3f287ac

Please sign in to comment.