Skip to content

Commit baff046

Browse files
committed
wrap checkboxes in a <span> and make them respond to Enter key
1 parent ca654e4 commit baff046

1 file changed

Lines changed: 22 additions & 15 deletions

File tree

components/dash-core-components/src/utils/optionRendering.tsx

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,28 @@ export const Option: React.FC<OptionProps> = ({
9292
aria-selected={isSelected}
9393
style={optionStyle}
9494
>
95-
<input
96-
type={inputType}
97-
checked={isSelected}
98-
name={id}
99-
value={
100-
typeof option.value === 'boolean'
101-
? `${option.value}`
102-
: option.value
103-
}
104-
disabled={!!option.disabled}
105-
onChange={() => onChange(option)}
106-
readOnly
107-
className={inputClassNames.join(' ')}
108-
style={inputStyle}
109-
/>
95+
<span className="dash-options-list-option-wrapper">
96+
<input
97+
type={inputType}
98+
checked={isSelected}
99+
name={id}
100+
value={
101+
typeof option.value === 'boolean'
102+
? `${option.value}`
103+
: option.value
104+
}
105+
disabled={!!option.disabled}
106+
onChange={() => onChange(option)}
107+
onKeyUp={e => {
108+
if (e.key === 'Enter' && inputType === 'checkbox') {
109+
onChange(option);
110+
}
111+
}}
112+
readOnly
113+
className={inputClassNames.join(' ')}
114+
style={inputStyle}
115+
/>
116+
</span>
110117
<span
111118
className={labelClassNames.join(' ')}
112119
style={labelStyle}

0 commit comments

Comments
 (0)