File tree Expand file tree Collapse file tree 3 files changed +43
-4
lines changed
Expand file tree Collapse file tree 3 files changed +43
-4
lines changed Original file line number Diff line number Diff line change 1- <!--
21### Breaking Changes
32
43### Features
54
65### Bug Fixes and Improvements
7- - Fix problem with expandSubsequently resolving before expanding all items
6+ - Fix problem with expandSubsequently resolving before expanding all items (#403 )
7+ - Improve behavior for cases where item containers have margin (#404 )
8+
89### Other Changes
9- -->
Original file line number Diff line number Diff line change @@ -4,7 +4,12 @@ export const computeItemHeight = (treeId: string) => {
44 const firstItem = getDocument ( ) ?. querySelector < HTMLElement > (
55 `[data-rct-tree="${ treeId } "] [data-rct-item-container="true"]`
66 ) ;
7- return firstItem ?. offsetHeight ?? 5 ;
7+ if ( firstItem ) {
8+ const style = getComputedStyle ( firstItem ) ;
9+ // top margin flows into the bottom margin of the previous item, so ignore it
10+ return firstItem . offsetHeight + parseFloat ( style . marginBottom ) ;
11+ }
12+ return 5 ;
813} ;
914
1015export const isOutsideOfContainer = ( e : DragEvent , treeBb : DOMRect ) =>
Original file line number Diff line number Diff line change @@ -669,3 +669,37 @@ export const RightToLeftRenderers = () => (
669669 < Tree treeId = "tree-1" rootItem = "root" treeLabel = "Tree Example" />
670670 </ UncontrolledTreeEnvironment >
671671) ;
672+
673+ export const ItemContainersWithMargin = ( ) => (
674+ < UncontrolledTreeEnvironment < string >
675+ canDragAndDrop
676+ canDropOnFolder
677+ canReorderItems
678+ dataProvider = {
679+ new StaticTreeDataProvider ( longTree . items , ( item , data ) => ( {
680+ ...item ,
681+ data,
682+ } ) )
683+ }
684+ getItemTitle = { item => item . data }
685+ viewState = { {
686+ 'tree-1' : {
687+ expandedItems : [
688+ 'Fruit' ,
689+ 'Meals' ,
690+ 'America' ,
691+ 'Europe' ,
692+ 'Asia' ,
693+ 'Desserts' ,
694+ ] ,
695+ } ,
696+ } }
697+ >
698+ < style >
699+ {
700+ '.rct-tree-item-title-container { margin-top: 10px; margin-bottom: 20px;}'
701+ }
702+ </ style >
703+ < Tree treeId = "tree-1" rootItem = "root" treeLabel = "Tree Example" />
704+ </ UncontrolledTreeEnvironment >
705+ ) ;
You can’t perform that action at this time.
0 commit comments