Skip to content

Commit

Permalink
Pro Dashboard Form elements must have labels [sc-74561] (#890)
Browse files Browse the repository at this point in the history
* Pro Dashboard Form elements must have labels [sc-74561]

* some changes

* improvements

* remove extra space
  • Loading branch information
meetup-oleksandr-dudiuk committed Oct 6, 2023
1 parent 838c7f9 commit 6f68f18
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/forms/Checkbox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class Checkbox extends React.PureComponent {
}

handleKeyPress = e => {
if (e.key === 'Enter') {
if (e.key === ' ') {
this.props.onChange && this.props.onChange(e);

if (this.props.controlled) {
Expand Down Expand Up @@ -86,7 +86,6 @@ export class Checkbox extends React.PureComponent {
className="checkbox"
role="checkbox"
aria-checked={stateChecked}
aria-label="checkbox"
tabIndex={0}
onKeyPress={this.handleKeyPress}
>
Expand All @@ -102,6 +101,9 @@ export class Checkbox extends React.PureComponent {
onChange={this.onChange}
readOnly={!this.onChange || disabled}
name={name}
aria-label={
typeof label === 'string' ? `${label} - checkbox` : 'checkbox'
}
value={`${value}`}
/>
<span>{label}</span>
Expand Down
4 changes: 2 additions & 2 deletions src/forms/__snapshots__/checkbox.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ exports[`Checkbox basic renders checked checkbox 1`] = `
>
<span
aria-checked={true}
aria-label="checkbox"
className="checkbox"
data-swarm-checkbox-field="checked"
onKeyPress={[Function]}
Expand All @@ -20,6 +19,7 @@ exports[`Checkbox basic renders checked checkbox 1`] = `
/>
</span>
<input
aria-label="Hello! - checkbox"
checked={true}
id="hello"
name="greeting"
Expand All @@ -40,13 +40,13 @@ exports[`Checkbox basic renders unchecked checkbox 1`] = `
>
<span
aria-checked={false}
aria-label="checkbox"
className="checkbox"
onKeyPress={[Function]}
role="checkbox"
tabIndex={0}
/>
<input
aria-label="Hello! - checkbox"
checked={false}
id="hello"
name="greeting"
Expand Down

0 comments on commit 6f68f18

Please sign in to comment.