Skip to content

Commit

Permalink
Merge pull request #2807 from SUI-Components/a11y-label-open-props
Browse files Browse the repository at this point in the history
feat(components/atom/label): open props
  • Loading branch information
andresin87 authored Jan 17, 2025
2 parents 25f6a9e + d70b366 commit aeffad9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
10 changes: 8 additions & 2 deletions components/atom/label/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,15 @@ const AtomLabel: FC<AtomLabelProps> = ({
fontSize,
htmlFor,
onClick,
className
className,
...props
}) => (
<label htmlFor={htmlFor ?? name} className={getClass({inline, type, fontSize, className})} onClick={onClick}>
<label
htmlFor={htmlFor ?? name}
className={getClass({inline, type, fontSize, className})}
onClick={onClick}
{...props}
>
{text}
{Boolean(optionalText) && <span className="sui-AtomLabel-optionalText">{optionalText}</span>}
</label>
Expand Down
24 changes: 24 additions & 0 deletions components/atom/label/test/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,30 @@ describe(json.name, () => {
// Then
expect(findClassName(container.innerHTML)).to.not.be.null
})

it('should have data attributes', () => {
// Given
const props = {'data-attribute': 'data-attribute'}

// When
const {container} = setup(props)
const element = container.querySelector('[data-attribute]')

// Then
expect(element).to.not.be.null
})

it('should have aria attributes', () => {
// Given
const props = {'aria-attribute': 'aria-attribute'}

// When
const {container} = setup(props)
const element = container.querySelector('[aria-attribute]')

// Then
expect(element).to.not.be.null
})
})

describe('AtomLabelTypes', () => {
Expand Down

0 comments on commit aeffad9

Please sign in to comment.