Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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 src/components/Button/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ export const ButtonWrapper = styled.button<StyledButtonType>`
: `

`}
&:focus {
outline: auto;
}
.button-face {
position: relative;
display: flex;
Expand Down
25 changes: 23 additions & 2 deletions src/components/Checkbox/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useRef } from 'react';
import withCheckHOC from '@components/Helpers/withCheckHOC';
import { CheckmarkWrapper, CheckboxLabel } from './styles';
import { CheckboxProps } from './types';
Expand All @@ -8,6 +8,7 @@ import { isEmpty } from '@utils';

const Checkbox = (props: CheckboxProps) => {
const { isChecked, handleChange, colorConfig, colorMode, children, ...propsToFwd } = props;
const checkboxRef = useRef<HTMLInputElement>(null);
const defaultColorConfig =
colorGuide[colorMode === 'light' ? 'lightComponents' : 'darkComponents'].checkbox;
const checkboxColorConfig = isEmpty(colorConfig)
Expand All @@ -16,12 +17,32 @@ const Checkbox = (props: CheckboxProps) => {

return (
<CheckboxLabel>
<input {...propsToFwd} type="checkbox" checked={isChecked} onChange={handleChange} />
<input
tabIndex={-1}
{...propsToFwd}
type="checkbox"
checked={isChecked}
onChange={handleChange}
ref={checkboxRef}
/>
<Row>
<CheckmarkWrapper
colorConfig={checkboxColorConfig}
hasChildren={children ? true : false}
checked={isChecked}
tabIndex={0}
onClick={(clickEvent) => {
clickEvent.preventDefault();
checkboxRef.current?.click();
}}
role="checkbox"
aria-checked={isChecked}
onKeyDown={(keydownEvent) => {
let key = keydownEvent.code;
if (key === 'Space' || key === 'Enter') {
checkboxRef.current?.click();
}
}}
>
<span className="checkmark">
<svg
Expand Down
12 changes: 11 additions & 1 deletion src/components/Radio/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,27 @@ const Radio = (props: RadioProps) => {

const RadioStyledButton = () => (
<StyledRadio
onClick={() => radioRef?.current?.click()}
onClick={(clickEvent) => {
clickEvent.preventDefault();
radioRef?.current?.click();
}}
onKeyDown={(clickEvent) => {
const key = clickEvent.code;
console.log(key);
Comment thread
negxative marked this conversation as resolved.
Outdated
if (key === 'Enter' || key === 'Space') radioRef?.current?.click();
}}
colorConfig={
isEmpty(colorConfig) ? defaultColorConfig : colorConfig ?? defaultColorConfig
}
tabIndex={0}
>
<input
id={id}
ref={radioRef}
type="radio"
checked={isChecked}
onChange={handleChange}
tabIndex={-1}
{...propsToFwd}
/>
<span className="checkmark"> </span>
Expand Down