Skip to content

Commit

Permalink
Fix(web-react): Do not render empty style prop
Browse files Browse the repository at this point in the history
  • Loading branch information
literat committed Jan 10, 2024
1 parent 05b5803 commit 5bd5dfa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/web-react/src/hooks/__tests__/styleProps.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { renderHook } from '@testing-library/react-hooks';
import { useStyleProps } from '../styleProps';
import { StyleProps } from '../../types';
import { useStyleProps } from '../styleProps';

describe('styleProps', () => {
describe('#useStyleProps', () => {
Expand All @@ -9,11 +9,12 @@ describe('styleProps', () => {
{ UNSAFE_style: { 'vertical-align': 'center' }, UNSAFE_className: 'Button' },
{ className: 'Button', style: { 'vertical-align': 'center' } },
],
[{ role: 'button' }, { UNSAFE_className: undefined, style: {} }],
[{ role: 'button' }, { UNSAFE_className: undefined, style: undefined }],
[
{ role: 'button', UNSAFE_style: { 'vertical-align': 'center' } },
{ className: undefined, style: { 'vertical-align': 'center' } },
],
[{ role: 'button' }, { className: undefined, style: undefined }],
])('should use UNSAFE_style and UNSAFE_className props', (input, expected) => {
expect(useStyleProps(input as StyleProps).styleProps).toEqual(expected);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/web-react/src/hooks/styleProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function useStyleProps<T extends StyleProps>(props: T): StylePropsResult
}

const styleProps = {
style,
style: Object.keys(style).length > 0 ? style : undefined,
className: UNSAFE_className,
};

Expand Down

0 comments on commit 5bd5dfa

Please sign in to comment.