File tree 3 files changed +43
-4
lines changed
3 files changed +43
-4
lines changed Original file line number Diff line number Diff line change 1
- <!--
2
1
### Breaking Changes
3
2
4
3
### Features
5
4
6
5
### 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
+
8
9
### Other Changes
9
- -->
Original file line number Diff line number Diff line change @@ -4,7 +4,12 @@ export const computeItemHeight = (treeId: string) => {
4
4
const firstItem = getDocument ( ) ?. querySelector < HTMLElement > (
5
5
`[data-rct-tree="${ treeId } "] [data-rct-item-container="true"]`
6
6
) ;
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 ;
8
13
} ;
9
14
10
15
export const isOutsideOfContainer = ( e : DragEvent , treeBb : DOMRect ) =>
Original file line number Diff line number Diff line change @@ -669,3 +669,37 @@ export const RightToLeftRenderers = () => (
669
669
< Tree treeId = "tree-1" rootItem = "root" treeLabel = "Tree Example" />
670
670
</ UncontrolledTreeEnvironment >
671
671
) ;
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