Skip to content

Commit bc4ebce

Browse files
LianaHusAniket-Engg
authored andcommitted
fixing bottom padding of FE for long trees
1 parent 295f587 commit bc4ebce

File tree

1 file changed

+4
-39
lines changed

1 file changed

+4
-39
lines changed

libs/remix-ui/workspace/src/lib/components/flat-tree.tsx

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,17 @@ import { fileDecoration, FileDecorationIcons } from '@remix-ui/file-decorators';
1111
export default function useOnScreen(ref: RefObject<HTMLElement>) {
1212

1313
const [isIntersecting, setIntersecting] = useState(false)
14-
1514
const observer = useMemo(() => new IntersectionObserver(
1615
([entry]) => setIntersecting(entry.isIntersecting)
1716
), [ref])
1817

19-
2018
useEffect(() => {
2119
observer.observe(ref.current)
2220
return () => observer.disconnect()
2321
}, [])
2422

2523
return isIntersecting
2624
}
27-
2825
interface FlatTreeProps {
2926
files: { [x: string]: Record<string, FileType> },
3027
flatTree: FileType[],
@@ -39,7 +36,6 @@ interface FlatTreeProps {
3936
moveFile: (dest: string, src: string) => void
4037
moveFolder: (dest: string, src: string) => void
4138
fileState: fileDecoration[]
42-
4339
}
4440

4541
let mouseTimer: any = {
@@ -63,17 +59,8 @@ export const FlatTree = (props: FlatTreeProps) => {
6359
const [dragSource, setDragSource] = useState<FileType>()
6460
const [isDragging, setIsDragging] = useState<boolean>(false)
6561
const ref = useRef(null)
66-
const [size, setSize] = useState(0)
6762
const containerRef = useRef<HTMLDivElement>(null)
6863
const virtuoso = useRef<VirtuosoHandle>(null)
69-
const isOnScreen = useOnScreen(containerRef)
70-
71-
useEffect(() => {
72-
if (isOnScreen) {
73-
setViewPortHeight()
74-
}
75-
}, [isOnScreen])
76-
7764

7865
const labelClass = (file: FileType) =>
7966
props.focusEdit.element === file.path
@@ -181,25 +168,6 @@ export const FlatTree = (props: FlatTreeProps) => {
181168
setShowMouseOverTarget(false)
182169
}
183170

184-
185-
const setViewPortHeight = () => {
186-
const boundingRect = containerRef.current.getBoundingClientRect()
187-
setSize(boundingRect.height - 40)
188-
}
189-
190-
191-
useEffect(() => {
192-
window.addEventListener('resize', setViewPortHeight)
193-
return () => {
194-
window.removeEventListener('resize', setViewPortHeight)
195-
}
196-
}, [])
197-
198-
useEffect(() => {
199-
setViewPortHeight()
200-
}, [containerRef.current])
201-
202-
203171
useEffect(() => {
204172
if (focusEdit && focusEdit.element) {
205173
const index = flatTree.findIndex((item) => item.path === focusEdit.element)
@@ -259,12 +227,12 @@ export const FlatTree = (props: FlatTreeProps) => {
259227
expandPath={expandPath}
260228
>
261229
<div data-id="treeViewUltreeViewMenu"
262-
className='d-flex h-100 w-100'
230+
className='d-flex h-100 w-100 pb-2'
263231
onClick={handleTreeClick}
264232
onMouseLeave={onMouseLeave}
265233
onMouseMove={onMouseMove}
266234
onContextMenu={handleContextMenu}>
267-
{showMouseOverTarget && mouseOverTarget && !isDragging &&
235+
{ showMouseOverTarget && mouseOverTarget && !isDragging &&
268236
<Popover id='popover-basic'
269237
placement='top'
270238
ref={ref}
@@ -277,22 +245,19 @@ export const FlatTree = (props: FlatTreeProps) => {
277245
minWidth: 'fit-content'
278246
}
279247
}>
280-
<Popover.Content
281-
className='text-wrap p-1 px-2 bg-secondary w-100'
282-
>
248+
<Popover.Content className='text-wrap p-1 px-2 bg-secondary w-100'>
283249
{mouseOverTarget && mouseOverTarget.path}
284250
</Popover.Content>
285251
</Popover>
286252
}
287253
<Virtuoso
288254
ref={virtuoso}
289-
style={{ height: `${size}px`, width: '100%' }}
255+
style={{ height: `100%`, width: '100%' }}
290256
totalCount={Object.keys(flatTree).length}
291257
itemContent={index => Row(index)}
292258
/>
293259
</div>
294260
</FlatTreeDrop>
295261
</div>
296262
</>)
297-
298263
}

0 commit comments

Comments
 (0)