88 Text ,
99 Textarea ,
1010} from '@codesandbox/components' ;
11+ import { createGlobalStyle } from 'styled-components' ;
1112import css from '@styled-system/css' ;
1213import { CommentFragment } from 'app/graphql/types' ;
1314import { useOvermind } from 'app/overmind' ;
@@ -127,23 +128,20 @@ export const Dialog: React.FC = () => {
127128 < DragHandle onPan = { onDragHandlerPan } >
128129 < DialogHeader comment = { comment } hasShadow = { scrollTop > 0 } />
129130 </ DragHandle >
130- < Stack
131- direction = "vertical"
132- css = { { overflow : 'auto' } }
133- ref = { listRef }
134- >
131+ < Element as = "div" css = { { overflow : 'auto' } } ref = { listRef } >
135132 < CommentBody
136133 comment = { comment }
137134 editing = { editing }
138135 setEditing = { setEditing }
136+ hasReplies = { replies . length }
139137 />
140138 { replies . length ? (
141139 < Replies
142140 replies = { replies }
143141 repliesRenderedCallback = { ( ) => setRepliesRendered ( true ) }
144142 />
145143 ) : null }
146- </ Stack >
144+ </ Element >
147145 < AddReply
148146 comment = { comment }
149147 onSubmit = { ( ) => {
@@ -226,15 +224,25 @@ const DialogAddComment: React.FC<{
226224 ) ;
227225} ;
228226
227+ /** When the dialog is dragged outside the window
228+ * It creates a scrollbar. We want to disable overflow
229+ * when the drag handle is DOM
230+ */
231+
232+ const GlobalStyles = createGlobalStyle `
233+ body { overflow: hidden; }
234+ ` ;
235+
229236const DragHandle : React . FC < {
230237 onPan : ( deltaX : number , deltaY : number ) => void ;
231238} > = ( { onPan, children } ) => (
232239 < motion . div
233240 onPan = { ( _ , info ) => {
234241 onPan ( info . delta . x , info . delta . y ) ;
235242 } }
236- style = { { cursor : 'move' } }
243+ style = { { cursor : 'move' , zIndex : 2 } }
237244 >
245+ < GlobalStyles />
238246 { children }
239247 </ motion . div >
240248) ;
@@ -252,7 +260,6 @@ const DialogHeader = ({ comment, hasShadow }) => {
252260 paddingRight = { 2 }
253261 marginBottom = { 2 }
254262 css = { css ( {
255- zIndex : 2 ,
256263 boxShadow : theme =>
257264 hasShadow
258265 ? `0px 32px 32px ${ theme . colors . dialog . background } `
@@ -293,7 +300,7 @@ const DialogHeader = ({ comment, hasShadow }) => {
293300 ) ;
294301} ;
295302
296- const CommentBody = ( { comment, editing, setEditing } ) => {
303+ const CommentBody = ( { comment, editing, setEditing, hasReplies } ) => {
297304 const { state, actions } = useOvermind ( ) ;
298305
299306 return (
@@ -333,7 +340,7 @@ const CommentBody = ({ comment, editing, setEditing }) => {
333340 marginX = { 4 }
334341 paddingBottom = { 6 }
335342 css = { css ( {
336- borderBottom : '1px solid' ,
343+ borderBottom : hasReplies ? '1px solid' : 'none ',
337344 borderColor : 'sideBar.border' ,
338345 } ) }
339346 >
@@ -371,7 +378,7 @@ const Replies = ({ replies, repliesRenderedCallback }) => {
371378 } , [ repliesLoaded , isAnimating , repliesRenderedCallback ] ) ;
372379
373380 return (
374- < motion . div
381+ < motion . ul
375382 initial = { { height : repliesLoaded ? 0 : SKELETON_HEIGHT } }
376383 animate = { { height : 'auto' } }
377384 transition = { {
@@ -381,6 +388,7 @@ const Replies = ({ replies, repliesRenderedCallback }) => {
381388 style = { {
382389 minHeight : repliesLoaded ? 0 : SKELETON_HEIGHT ,
383390 overflow : 'visible' ,
391+ paddingLeft : 0 ,
384392 } }
385393 onAnimationComplete = { ( ) => setAnimating ( false ) }
386394 >
@@ -393,7 +401,7 @@ const Replies = ({ replies, repliesRenderedCallback }) => {
393401 ) : (
394402 < SkeletonReply />
395403 ) }
396- </ motion . div >
404+ </ motion . ul >
397405 ) ;
398406} ;
399407
@@ -418,7 +426,8 @@ const AddReply = ({ comment, ...props }) => {
418426 border : 'none' ,
419427 borderTop : '1px solid' ,
420428 borderColor : 'sideBar.border' ,
421- paddingX : 4 ,
429+ borderRadius : 0 ,
430+ padding : 4 ,
422431 } ) }
423432 value = { value }
424433 onChange = { e => setValue ( e . target . value ) }
0 commit comments