fix(fuselage): do not render GridItem for null or boolean children in… · RocketChat/Rocket.Chat@d11d1a5 · GitHub
Skip to content

Commit d11d1a5

Browse files
committed
fix(fuselage): do not render GridItem for null or boolean children in CardGrid
Closes #42804 Signed-off-by: Aryan Sachin <aryansachinixd@gmail.com>
1 parent 9209eae commit d11d1a5

3 files changed

Lines changed: 25 additions & 3 deletions

File tree

Lines changed: 5 additions & 0 deletions

‎packages/fuselage/src/components/CardGrid/CardGrid.spec.tsx‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { composeStories } from '@storybook/react-webpack5';
22
import { axe } from 'jest-axe';
33

4+
import CardGrid from './CardGrid';
45
import * as stories from './CardGrid.stories';
56
import { render } from '../../testing';
67

@@ -13,4 +14,20 @@ describe('[CardGrid Rendering]', () => {
1314
const results = await axe(container);
1415
expect(results).toHaveNoViolations();
1516
});
17+
18+
it('does not render GridItem for null, undefined, or boolean children', () => {
19+
const { container } = render(
20+
<CardGrid>
21+
<div>Card 1</div>
22+
{null}
23+
{undefined}
24+
{false}
25+
{true}
26+
<div>Card 2</div>
27+
</CardGrid>,
28+
);
29+
30+
const items = container.querySelectorAll('.rcx-card-grid__item');
31+
expect(items).toHaveLength(2);
32+
});
1633
});

‎packages/fuselage/src/components/CardGrid/CardGrid.tsx‎

Lines changed: 3 additions & 3 deletions

0 commit comments

Comments
 (0)