Skip to content

Commit

Permalink
Tree respects size prop regardless of virtualization (#2327)
Browse files Browse the repository at this point in the history
  • Loading branch information
r100-stack authored Nov 5, 2024
1 parent 5b326c8 commit 2d24a62
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/few-apples-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@itwin/itwinui-react': patch
---

Fixed a `Tree` bug where the `size` prop was not respected when virtualization was enabled.
15 changes: 10 additions & 5 deletions packages/itwinui-react/src/core/Tree/Tree.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,13 @@ it('should set correct computed aria attributes to nodes', () => {
expect(node3_1.getAttribute('aria-posinset')).toBe('1');
});

it('should respect size prop', () => {
const { container } = renderComponent({ props: { size: 'small' } });
const tree = container.querySelector('.iui-tree') as HTMLElement;
expect(tree).toHaveAttribute('data-iui-size', 'small');
});
it.each([true, false])(
'should respect size prop (enableVirtualization=%s)',
(enableVirtualization) => {
const { container } = renderComponent({
props: { size: 'small', enableVirtualization },
});
const tree = container.querySelector('.iui-tree') as HTMLElement;
expect(tree).toHaveAttribute('data-iui-size', 'small');
},
);
1 change: 1 addition & 0 deletions packages/itwinui-react/src/core/Tree/Tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ export const Tree = <T,>(props: TreeProps<T>) => {
onKeyDown={handleKeyDown}
ref={treeRef}
className={className}
data-iui-size={size === 'small' ? 'small' : undefined}
style={style}
{...rest}
/>
Expand Down

0 comments on commit 2d24a62

Please sign in to comment.