Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(web-react): Do not render empty style prop #1179

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading